From: Peter Rajnoha <prajnoha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] Revert to old glibc behaviour for vsnprintf used in emit_to_buffer function
Date: Mon, 13 Sep 2010 16:36:10 +0200 [thread overview]
Message-ID: <4C8E36DA.2050707@redhat.com> (raw)
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 bug #633033 to be undetected and pass throught the check,
corrupting the metadata!)
Peter
---
lib/misc/lvm-string.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c
index 7eed799..82a3e94 100644
--- a/lib/misc/lvm-string.c
+++ b/lib/misc/lvm-string.c
@@ -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;
next reply other threads:[~2010-09-13 14:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-13 14:36 Peter Rajnoha [this message]
2010-09-20 12:35 ` [PATCH] Revert to old glibc behaviour for vsnprintf used in emit_to_buffer function Alasdair G Kergon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C8E36DA.2050707@redhat.com \
--to=prajnoha@redhat.com \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.