Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix potential buffer overflow in vperror

  • Loading branch information...
commit 7fc4fcc926ec2be9c762e44c49ef41fa7739b2e4 1 parent a0a7032
@trondn trondn authored dustin committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 util.c
View
6 util.c
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.