Skip to content

Commit

Permalink
If sysconf(_SC_HOST_NAME_MAX) returns 0, just use 255.
Browse files Browse the repository at this point in the history
This should not actually be possible.
  • Loading branch information
millert committed Dec 4, 2023
1 parent 8faf432 commit 24f4439
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/gethostname.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sudo_gethostname_v1(void)

#ifdef _SC_HOST_NAME_MAX
host_name_max = (size_t)sysconf(_SC_HOST_NAME_MAX);
if (host_name_max == (size_t)-1)
if ((ssize_t)host_name_max <= 0)
#endif
host_name_max = 255; /* POSIX and historic BSD */

Expand Down

0 comments on commit 24f4439

Please sign in to comment.