--- jcr-0.2.4.orig/jcomp/jcr_elements.c 2005-12-11 00:23:54 +0400 +++ jcr-0.2.4.orig/jcomp/jcr_elements.c 2005-12-11 00:28:17 +0400 @@ -22,6 +22,14 @@ $Id: jcr_elements.c,v 1.19 2004/07/21 15 #include "jcomp.h" +static int check_tag_name(char *name, char* needle, int size) +{ + if(strlen(name) != strlen(needle)) + return strlen(name) - strlen(needle); + + return strncasecmp(name, needle, strlen(needle)); +} + void jcr_start_element(void *m, const char *name, const char **attrib) { extern jcr_instance jcr; pool p; @@ -31,12 +39,12 @@ void jcr_start_element(void *m, const ch switch (jcr->stream_state) { case _STREAM_INIT_STATE: - if (strncasecmp(name, "stream:stream", 13) == 0) { + if (check_tag_name(name, "stream:stream", 13) == 0) { char *pass = xmlnode_get_data(xmlnode_get_tag(jcr->config,"secret")); int i = 0; if (attrib == NULL) return; while (attrib[i] != '\0') { - if (strncasecmp(attrib[i], "id", 2) == 0) + if (check_tag_name(attrib[i], "id", 2) == 0) break; i += 2; } @@ -89,7 +97,7 @@ void jcr_end_element(void *m, const char case _STREAM_INIT_STATE: case _STREAM_AUTH_SENT: - if (strncasecmp(name, "handshake", 9) == 0) { + if (check_tag_name(name, "handshake", 9) == 0) { jcr->stream_state = _STREAM_CONNECTED; log_debug(JDBG, " received"); } @@ -99,19 +107,19 @@ void jcr_end_element(void *m, const char log_warn(JDBG, "jcr->current == NULL, closing stream"); jcr_main_close_stream(); } else { - if (strncasecmp(name, "stream:error", 12) == 0) { + if (check_tag_name(name, "stream:error", 12) == 0) { log_warn(JDBG, "'stream:error' on server stream: '%s'", xmlnode2str(jcr->current)); // jcr_main_close_stream(); return; } - if (strncasecmp(name, "stream", 6) == 0) { + if (check_tag_name(name, "stream", 6) == 0) { log_warn(JDBG, "End of Stream from server: '%s'", xmlnode2str(jcr->current)); jcr_main_close_stream(); return; } - if (strncasecmp(name, "stream:stream", 13) == 0) { + if (check_tag_name(name, "stream:stream", 13) == 0) { log_warn(JDBG, "End of Stream from server: '%s'", xmlnode2str(jcr->current)); jcr_main_close_stream(); return;