Add ssizeof macro that returns ssize_t.

We can use this instead of casting the result of size_t to int.
Also change checks for snprintf() returning <=0 to <0.
This commit is contained in:
Todd C. Miller
2019-06-25 09:45:10 -06:00
parent 81602ad086
commit 9d8f374397
17 changed files with 31 additions and 28 deletions

View File

@@ -653,7 +653,7 @@ sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level
va_copy(ap2, ap);
buflen = fmt ? vsnprintf(static_buf, sizeof(static_buf), fmt, ap2) : 0;
va_end(ap2);
if (buflen >= (int)sizeof(static_buf)) {
if (buflen >= ssizeof(static_buf)) {
va_list ap3;
/* Not enough room in static buf, allocate dynamically. */
@@ -763,7 +763,7 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con
buflen += strlen(*av) + 1;
buflen--;
}
if (buflen >= (int)sizeof(static_buf)) {
if (buflen >= ssizeof(static_buf)) {
buf = malloc(buflen + 1);
if (buf == NULL)
goto out;