applied some segfault patches of Adrien Krunch Kunysz (thanks to Adrien!)

This commit is contained in:
Anselm R. Garbe 2007-01-11 11:35:02 +01:00
parent 148029905b
commit 44e0417e14

5
sic.c
View File

@ -142,7 +142,8 @@ parsesrv(char *msg) {
* <crlf> ::= CR LF * <crlf> ::= CR LF
*/ */
if(msg[0] == ':') { /* check prefix */ if(msg[0] == ':') { /* check prefix */
p = strchr(msg, ' '); if (!(p = strchr(msg, ' ')))
return;
*p = 0; *p = 0;
for(++p; *p == ' '; p++); for(++p; *p == ' '; p++);
cmd = p; cmd = p;
@ -162,7 +163,7 @@ parsesrv(char *msg) {
argv[Ttext] = ++p; argv[Ttext] = ++p;
} }
tokenize(&argv[Tcmd], Tlast - Tcmd, cmd, ' '); tokenize(&argv[Tcmd], Tlast - Tcmd, cmd, ' ');
if(!strncmp("PONG", argv[Tcmd], 5)) if(!argv[Tcmd] || !strncmp("PONG", argv[Tcmd], 5))
return; return;
else if(!strncmp("PING", argv[Tcmd], 5)) { else if(!strncmp("PING", argv[Tcmd], 5)) {
snprintf(bufout, sizeof bufout, "PONG %s\r\n", argv[Ttext]); snprintf(bufout, sizeof bufout, "PONG %s\r\n", argv[Ttext]);