diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-03-06 15:30:42 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-03-06 15:43:05 +0100 |
commit | 6b03bb52b9dab87523945d3c9ef5c0dbf00dfd23 (patch) | |
tree | 6df8285797c3319731f7e469830f97c2a666a1da /src/socket.c | |
parent | bfbdc814984f25e09af8820d9f409100bf0248d2 (diff) | |
download | gnutls-6b03bb52b9dab87523945d3c9ef5c0dbf00dfd23.tar.gz |
cli sockets: check for a digit prior using atoi
Diffstat (limited to 'src/socket.c')
-rw-r--r-- | src/socket.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c index f662c558e2..7ed9c3afac 100644 --- a/src/socket.c +++ b/src/socket.c @@ -362,6 +362,9 @@ const char *port_to_service(const char *sport, const char *proto) unsigned int port; struct servent *sr; + if (!c_isdigit(sport[0])) + return sport; + port = atoi(sport); if (port == 0) return sport; @@ -371,7 +374,7 @@ const char *port_to_service(const char *sport, const char *proto) sr = getservbyport(port, proto); if (sr == NULL) { fprintf(stderr, - "Warning: getservbyport() failed. Using port number as service.\n"); + "Warning: getservbyport(%s) failed. Using port number as service.\n", sport); return sport; } |