Skip to content

Commit

Permalink
Fix sign compare warning
Browse files Browse the repository at this point in the history
Store the result of asprintf() in an int, not size_t.
  • Loading branch information
millert committed Aug 14, 2024
1 parent 46274e7 commit 6b90acb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sudo.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,13 @@ get_user_info(struct user_details *ud)

ttydev = get_process_ttyname(path, sizeof(path));
if (ttydev != (dev_t)-1) {
int len;
#if SIZEOF_DEV_T == SIZEOF_LONG
n = asprintf(&info[++i], "ttydev=%lu", (unsigned long)ttydev);
len = asprintf(&info[++i], "ttydev=%lu", (unsigned long)ttydev);
#else
n = asprintf(&info[++i], "ttydev=%llu", (unsigned long long)ttydev);
len = asprintf(&info[++i], "ttydev=%llu", (unsigned long long)ttydev);
#endif
if (n == -1)
if (len == -1)
goto oom;
info[++i] = sudo_new_key_val("tty", path);
if (info[i] == NULL)
Expand Down

0 comments on commit 6b90acb

Please sign in to comment.