/* $OpenBSD: vfprintf.c,v 1.67 2014/12/21 00:23:30 daniel Exp $ */
/*-
- * Copyright (c) 1999-2005, 2008, 2010-2015
+ * Copyright (c) 1999-2005, 2008, 2010-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
goto finish;
overflow:
- errno = ENOMEM;
+ errno = EOVERFLOW;
ret = -1;
finish:
goto finish;
overflow:
- errno = ENOMEM;
+ errno = EOVERFLOW;
ret = -1;
finish:
int
sudo_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
{
-
+ if (n > INT_MAX) {
+ errno = EOVERFLOW;
+ *str = '\0';
+ return -1;
+ }
return xxxprintf(&str, n, 0, fmt, ap);
}
#endif /* !HAVE_VSNPRINTF || PREFER_PORTABLE_SNPRINTF */
int ret;
va_list ap;
+ if (n > INT_MAX) {
+ errno = EOVERFLOW;
+ *str = '\0';
+ return -1;
+ }
va_start(ap, fmt);
ret = xxxprintf(&str, n, 0, fmt, ap);
va_end(ap);