summaryrefslogtreecommitdiff
path: root/src/libudev/libudev-util.c
diff options
context:
space:
mode:
authorklondike <klondike@xiscosoft.es>2013-04-01 21:07:57 +0200
committerIan Stakenvicius <axs@gentoo.org>2013-04-03 14:22:40 -0400
commit50758bdd96f5043e58d53419a83b565586fef914 (patch)
treec9d2ca84cad09156e6943b15bdcf716139be40ab /src/libudev/libudev-util.c
parentd8d626c7df9d352d123fad7187ccb1bb0a4d7806 (diff)
Fix buffer overflow
Signed-off-by: Ian Stakenvicius <axs@gentoo.org>
Diffstat (limited to 'src/libudev/libudev-util.c')
-rw-r--r--src/libudev/libudev-util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index 7d5cd30662..9371f32e9d 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -337,13 +337,15 @@ size_t util_strpcpyf(char **dest, size_t size, const char *src, ...)
va_list va;
int i;
+ if (!size) return 0; /*Nothing to do if size is 0*/
+
va_start(va, src);
i = vsnprintf(*dest, size, src, va);
if (i < (int)size) {
*dest += i;
size -= i;
} else {
- *dest += size;
+ *dest += size - 1;
size = 0;
}
va_end(va);