On Tue, 30 Nov 2004, Charles Duffy wrote:
> James,
>
> I notice that the management interface terminates its lines \0d \0a \00.
>
> Is the null termination intentional? If so, would you mind documenting it?
> It caused a few subtle issues until I figured out what was going on, so I
> wouldn't exactly mind if it went away.
>
> (I'm working on a CLR-based library, and maybe when it works a Gtk#
> frontend, for interacting w/ OpenVPN via said interface).
Aha, good catch... the null termination is a bug, it should just be \0d
\0a -- I will fix for beta19.
If you'd like an immediate fix, I've attached a patch.
James
--- openvpn-2.0_beta18/buffer.c 2004-11-17 04:10:43.000000000 -0600
+++ ./buffer.c 2004-11-30 23:50:17.563824952 -0600
@@ -441,11 +441,18 @@
#endif
{
struct buffer buf;
+
+ ASSERT (str);
+
#ifdef DMALLOC
buf_set_read (&buf, string_alloc_debug (str, NULL, file, line), strlen (str)
+ 1);
#else
buf_set_read (&buf, string_alloc (str, NULL), strlen (str) + 1);
#endif
+
+ if (buf.len > 0) /* Don't count trailing '\0' as part of length */
+ --buf.len;
+
return buf;
}