From: John Hodge Date: Mon, 7 Mar 2011 01:13:45 +0000 (+0800) Subject: Fixed not checking return value of recv() X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=bdf327ad73a99b62b0bf4302f3b8b03f301902fb;p=tpg%2Fopendispense2.git Fixed not checking return value of recv() --- diff --git a/src/client/main.c b/src/client/main.c index fd5915d..0995d3b 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -287,11 +287,11 @@ int main(int argc, char *argv[]) gbDryRun = 1; break; default: - if( !isdigit(argv[i][0]) ) { - fprintf(stderr, "%s: Unknown switch '%s'\n", argv[0], argv[i]); - ShowUsage(); - return RV_ARGUMENTS; - } +// if( !isdigit(argv[i][0]) ) { +// fprintf(stderr, "%s: Unknown switch '%s'\n", argv[0], argv[i]); +// ShowUsage(); +// return RV_ARGUMENTS; +// } if( text_argc + 1 == MAX_TXT_ARGS ) { fprintf(stderr, "ERROR: Too many arguments\n"); @@ -2160,6 +2160,10 @@ char *ReadLine(int Socket) } else { len = recv(Socket, buf+bufPos, BUFSIZ-1-bufPos, 0); + if( len < 0 ) { + free(ret); + return strdup("499 Client Connection Error\n"); + } buf[bufPos+len] = '\0'; }