1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Revert to old glibc behaviour for vsnprintf used in emit_to_buffer function.

Revert to old glibc behaviour for vsnprintf used in emit_to_buffer fn.
Otherwise, the check that follows would be wrong for new glibc versions.
This caused the rh bug #633033 to be undetected and pass throught the check,
corrupting the metadata!
This commit is contained in:
Peter Rajnoha 2010-09-20 14:25:27 +00:00
parent 48ae64529a
commit 70431c8146
2 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.74 -
==================================
Revert to old glibc behaviour for vsnprintf used in emit_to_buffer function.
Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit).
Add random suffix to archive file names to prevent races when being created.
Reinitialize archive and backup handling on toolcontext refresh.

View File

@ -27,6 +27,14 @@ int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...)
n = vsnprintf(*buffer, *size, fmt, ap);
va_end(ap);
/*
* Revert to old glibc behaviour (version <= 2.0.6) where snprintf
* returned -1 if buffer was too small. From glibc 2.1 it returns number
* of chars that would have been written had there been room.
*/
if (n < 0 || ((unsigned) n + 1 > *size))
n = -1;
if (n < 0 || ((size_t)n == *size))
return 0;