Skip to content

Commit

Permalink
Fix potential buffer overflow in vperror
Browse files Browse the repository at this point in the history
  • Loading branch information
trondn authored and dustin committed Feb 22, 2010
1 parent a0a7032 commit 7fc4fcc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ bool safe_strtol(const char *str, int32_t *out) {

void vperror(const char *fmt, ...) {
int old_errno = errno;
char buf[80];
char buf[1024];
va_list ap;

va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
if (vsnprintf(buf, sizeof(buf), fmt, ap) == -1) {
buf[sizeof(buf) - 1] = '\0';
}
va_end(ap);

errno = old_errno;
Expand Down

0 comments on commit 7fc4fcc

Please sign in to comment.