From: Ben Pfaff Date: Mon, 29 Dec 2008 21:26:19 +0000 (-0800) Subject: Make ds_cstr() always null-terminate the string. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1db8d9dc86e69d02eb21df641d71f2e0abd61aa3;p=openvswitch Make ds_cstr() always null-terminate the string. Most of the time the string in "struct ds" is null-terminated, but there seem to be a few corner cases where it is not. Make ds_cstr() always put in the null terminator, for safety. Thanks to Justin for pointing out the problem. --- diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index 0c5dd5f3..03efac07 100644 --- a/lib/dynamic-string.c +++ b/lib/dynamic-string.c @@ -199,8 +199,8 @@ ds_cstr(struct ds *ds) { if (!ds->string) { ds_reserve(ds, 0); - ds->string[0] = '\0'; } + ds->string[ds->length] = '\0'; return ds->string; }