From: Lennart Poettering Date: Sat, 25 Aug 2007 23:16:36 +0000 (+0000) Subject: properly use va_copy() when iterating more than once through a va_list; fix bad memor... X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=d32b1cf886980a6d8200d66895793081633cd596;p=catta properly use va_copy() when iterating more than once through a va_list; fix bad memory access by one byte; closes #164; identified by QuLogic git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1524 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-common/strlst.c b/avahi-common/strlst.c index 9ffa18e..f8be273 100644 --- a/avahi-common/strlst.c +++ b/avahi-common/strlst.c @@ -337,8 +337,11 @@ AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *f for (;;) { int n; AvahiStringList *nr; + va_list va2; - n = vsnprintf((char*) r->text, len+1, format, va); + va_copy(va2, va); + n = vsnprintf((char*) r->text, len, format, va2); + va_end(va2); if (n >= 0 && n < (int) len) break; @@ -355,7 +358,6 @@ AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *f r = nr; } - r->next = l; r->size = strlen((char*) r->text);