mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-22 15:03:34 +07:00
Fix buffer overflow
Signed-off-by: Ian Stakenvicius <axs@gentoo.org>
This commit is contained in:
parent
d8d626c7df
commit
50758bdd96
@ -337,13 +337,15 @@ size_t util_strpcpyf(char **dest, size_t size, const char *src, ...)
|
|||||||
va_list va;
|
va_list va;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!size) return 0; /*Nothing to do if size is 0*/
|
||||||
|
|
||||||
va_start(va, src);
|
va_start(va, src);
|
||||||
i = vsnprintf(*dest, size, src, va);
|
i = vsnprintf(*dest, size, src, va);
|
||||||
if (i < (int)size) {
|
if (i < (int)size) {
|
||||||
*dest += i;
|
*dest += i;
|
||||||
size -= i;
|
size -= i;
|
||||||
} else {
|
} else {
|
||||||
*dest += size;
|
*dest += size - 1;
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
Loading…
Reference in New Issue
Block a user