From: Michal Voců Date: Wed, 15 Feb 2006 14:19:33 +0000 (+0000) Subject: * add sanity checks to recognize IL protocol from garbage (eg. SOAP) X-Git-Tag: glite-lb-common_R_3_0_4~7 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=befb55a220536af7518357c675384efd12b58c1b;p=jra1mw.git * add sanity checks to recognize IL protocol from garbage (eg. SOAP) --- diff --git a/org.glite.lb.common/src/il_msg.c b/org.glite.lb.common/src/il_msg.c index 10f7a82..4154ee9 100644 --- a/org.glite.lb.common/src/il_msg.c +++ b/org.glite.lb.common/src/il_msg.c @@ -109,7 +109,7 @@ read_il_data(void *user_data, char **buffer, int (*reader)(void *, char *, const int)) { - char buf[17]; + char buf[17], *p; int ret, len; /* read 17 byte header */ @@ -117,7 +117,23 @@ read_il_data(void *user_data, if(len < 0) { goto err; } + + /* perform some sanity checks on the received header */ + if(buf[16] != '\n') { + len = -1; + goto err; + } buf[16] = 0; + /* skip leading spaces */ + for(p = buf; *p == ' '; p++); + /* skip digits */ + for(; (*p >= '0') && (*p <= '9'); p++); + /* this must be the end of string */ + if(*p != 0) { + len = -1; + goto err; + } + if((len=atoi(buf)) <= 0) { len = -1; goto err;