Fix error reporting for out-of-range port numbers.

This was found by simply adding -Wextra to the compilation flags.
This commit is contained in:
Sam Hocevar 2016-01-12 11:39:36 +01:00
parent 9ceb167e51
commit 401a67b569
2 changed files with 5 additions and 5 deletions

View File

@ -13,5 +13,5 @@ rinetd_SOURCES = rinetd.c match.c match.h
# _POSIX_C_SOURCE is for SA_RESTART and others
# _XOPEN_SOURCE is for struct sigaction
# _DEFAULT_SOURCE is for h_errno and gethostbyname-related macros
rinetd_CFLAGS = -std=c99 -D_XOPEN_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -Wall -Wwrite-strings -I.
rinetd_CFLAGS = -std=c99 -D_XOPEN_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Wwrite-strings -I.

View File

@ -397,11 +397,11 @@ void readConfiguration(void)
}
for (int i = 0; ; ) {
char *bindAddress;
unsigned short bindPort;
unsigned int bindPort;
char *connectAddress;
char *bindPortS;
char *connectPortS;
unsigned short connectPort;
unsigned int connectPort;
struct in_addr iaddr;
struct sockaddr_in saddr;
struct servent *service;
@ -503,7 +503,7 @@ void readConfiguration(void)
} else {
bindPort = atoi(bindPortS);
}
if ((bindPort == 0) || (bindPort >= 65536)) {
if (bindPort == 0 || bindPort >= 65536) {
syslog(LOG_ERR, "bind port missing "
"or out of range on file %s, line %d.\n", options.conf_file, lnum);
continue;
@ -526,7 +526,7 @@ void readConfiguration(void)
} else {
connectPort = atoi(connectPortS);
}
if ((connectPort == 0) || (connectPort >= 65536)) {
if (connectPort == 0 || connectPort >= 65536) {
syslog(LOG_ERR, "bind port missing "
"or out of range on file %s, %d.\n", options.conf_file, lnum);
continue;