* sysconf() may return -N values on some platforms or values larger than
the hard-coded 1024 buffer size for hostname. Use sizeof() instead
since the buffer is hardcoded anyway.
* also, use return instead of exit() on the test binary to reduce
warnings from static analysis compilers.
Detected by Coverity Scan. Issues 740392, 740484
struct addrinfo *hres = NULL, *hres_list;
int rc, count;
- rc = gethostname(hostname, sysconf(_SC_HOST_NAME_MAX));
+ rc = gethostname(hostname, sizeof(hostname)-1);
if (rc) {
fprintf(stderr, "%s| %s: ERROR: resolving hostname '%s' failed\n",
LogTime(), PROGRAM, hostname);
return NULL;
}
freeaddrinfo(hres);
- hostname[sysconf(_SC_HOST_NAME_MAX) - 1] = '\0';
+ hostname[sizeof(hostname)-1] = '\0';
return (xstrdup(hostname));
}
int
main(int argc, char *argv[])
{
-
const char *Token;
int count;
if (argc < 2) {
fprintf(stderr, "%s| %s: Error: No proxy server name given\n",
LogTime(), PROGRAM);
- exit(99);
+ return 99;
}
if (argc == 3) {
count = atoi(argv[2]);
fprintf(stdout, "Token: %s\n", Token ? Token : "NULL");
}
- exit(0);
+ return 0;
}
#else
int
main(int argc, char *argv[])
{
- exit(-1);
+ return -1;
}
#endif /* HAVE_GSSAPI */