Module Name: src Committed By: christos Date: Thu Mar 8 20:49:29 UTC 2012
Modified Files: src/external/gpl2/xcvs/dist/lib: vasnprintf.c Log Message: Don't use %n in the writable data segment. Fortified glibc complains. When the left hand does not communicate with the right hand. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/xcvs/dist/lib/vasnprintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl2/xcvs/dist/lib/vasnprintf.c diff -u src/external/gpl2/xcvs/dist/lib/vasnprintf.c:1.2 src/external/gpl2/xcvs/dist/lib/vasnprintf.c:1.3 --- src/external/gpl2/xcvs/dist/lib/vasnprintf.c:1.2 Wed Apr 8 12:27:51 2009 +++ src/external/gpl2/xcvs/dist/lib/vasnprintf.c Thu Mar 8 15:49:29 2012 @@ -562,13 +562,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *l break; } *p = dp->conversion; -#if USE_SNPRINTF - p[1] = '%'; - p[2] = 'n'; - p[3] = '\0'; -#else p[1] = '\0'; -#endif /* Construct the arguments for calling snprintf or sprintf. */ prefix_count = 0; @@ -596,28 +590,25 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *l { size_t maxlen; int count; - int retcount; maxlen = allocated - length; count = -1; - retcount = 0; #if USE_SNPRINTF # define SNPRINTF_BUF(arg) \ switch (prefix_count) \ { \ case 0: \ - retcount = SNPRINTF (result + length, maxlen, buf, \ - arg, &count); \ + count = SNPRINTF (result + length, maxlen, buf, \ + arg); \ break; \ case 1: \ - retcount = SNPRINTF (result + length, maxlen, buf, \ - prefixes[0], arg, &count); \ + count = SNPRINTF (result + length, maxlen, buf, \ + prefixes[0], arg); \ break; \ case 2: \ - retcount = SNPRINTF (result + length, maxlen, buf, \ - prefixes[0], prefixes[1], arg, \ - &count); \ + count = SNPRINTF (result + length, maxlen, buf, \ + prefixes[0], prefixes[1], arg); \ break; \ default: \ abort (); \ @@ -768,39 +759,6 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *l result. */ if (count < maxlen && result[length + count] != '\0') abort (); - /* Portability hack. */ - if (retcount > count) - count = retcount; - } - else - { - /* snprintf() doesn't understand the '%n' - directive. */ - if (p[1] != '\0') - { - /* Don't use the '%n' directive; instead, look - at the snprintf() return value. */ - p[1] = '\0'; - continue; - } - else - { - /* Look at the snprintf() return value. */ - if (retcount < 0) - { - /* HP-UX 10.20 snprintf() is doubly deficient: - It doesn't understand the '%n' directive, - *and* it returns -1 (rather than the length - that would have been required) when the - buffer is too small. */ - size_t bigger_need = - xsum (xtimes (allocated, 2), 12); - ENSURE_ALLOCATION (bigger_need); - continue; - } - else - count = retcount; - } } #endif