Author: jra Date: 2007-09-12 21:41:36 +0000 (Wed, 12 Sep 2007) New Revision: 25116
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25116 Log: Fix talloc_asprintf_append to do the right thing with truncated strings. Jeremy. Modified: branches/SAMBA_3_0_MAINT/source/lib/talloc/talloc.c branches/SAMBA_3_2/source/lib/talloc/talloc.c branches/SAMBA_3_2_0/source/lib/talloc/talloc.c branches/SAMBA_4_0/source/lib/talloc/talloc.c Changeset: Modified: branches/SAMBA_3_0_MAINT/source/lib/talloc/talloc.c =================================================================== --- branches/SAMBA_3_0_MAINT/source/lib/talloc/talloc.c 2007-09-12 12:36:42 UTC (rev 25115) +++ branches/SAMBA_3_0_MAINT/source/lib/talloc/talloc.c 2007-09-12 21:41:36 UTC (rev 25116) @@ -1215,8 +1215,7 @@ * accumulating output into a string buffer. **/ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) -{ - struct talloc_chunk *tc; +{ int len, s_len; va_list ap2; char c; @@ -1225,10 +1224,8 @@ return talloc_vasprintf(NULL, fmt, ap); } - tc = talloc_chunk_from_ptr(s); + s_len = strlen(s); - s_len = tc->size - 1; - va_copy(ap2, ap); len = vsnprintf(&c, 1, fmt, ap2); va_end(ap2); Modified: branches/SAMBA_3_2/source/lib/talloc/talloc.c =================================================================== --- branches/SAMBA_3_2/source/lib/talloc/talloc.c 2007-09-12 12:36:42 UTC (rev 25115) +++ branches/SAMBA_3_2/source/lib/talloc/talloc.c 2007-09-12 21:41:36 UTC (rev 25116) @@ -1226,8 +1226,7 @@ * accumulating output into a string buffer. **/ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) -{ - struct talloc_chunk *tc; +{ int len, s_len; va_list ap2; char c; @@ -1236,10 +1235,8 @@ return talloc_vasprintf(NULL, fmt, ap); } - tc = talloc_chunk_from_ptr(s); + s_len = strlen(s); - s_len = tc->size - 1; - va_copy(ap2, ap); len = vsnprintf(&c, 1, fmt, ap2); va_end(ap2); Modified: branches/SAMBA_3_2_0/source/lib/talloc/talloc.c =================================================================== --- branches/SAMBA_3_2_0/source/lib/talloc/talloc.c 2007-09-12 12:36:42 UTC (rev 25115) +++ branches/SAMBA_3_2_0/source/lib/talloc/talloc.c 2007-09-12 21:41:36 UTC (rev 25116) @@ -1226,8 +1226,7 @@ * accumulating output into a string buffer. **/ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) -{ - struct talloc_chunk *tc; +{ int len, s_len; va_list ap2; char c; @@ -1236,10 +1235,8 @@ return talloc_vasprintf(NULL, fmt, ap); } - tc = talloc_chunk_from_ptr(s); + s_len = strlen(s); - s_len = tc->size - 1; - va_copy(ap2, ap); len = vsnprintf(&c, 1, fmt, ap2); va_end(ap2); Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.c =================================================================== --- branches/SAMBA_4_0/source/lib/talloc/talloc.c 2007-09-12 12:36:42 UTC (rev 25115) +++ branches/SAMBA_4_0/source/lib/talloc/talloc.c 2007-09-12 21:41:36 UTC (rev 25116) @@ -1226,8 +1226,7 @@ * accumulating output into a string buffer. **/ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) -{ - struct talloc_chunk *tc; +{ int len, s_len; va_list ap2; char c; @@ -1236,10 +1235,8 @@ return talloc_vasprintf(NULL, fmt, ap); } - tc = talloc_chunk_from_ptr(s); + s_len = strlen(s); - s_len = tc->size - 1; - va_copy(ap2, ap); len = vsnprintf(&c, 1, fmt, ap2); va_end(ap2);