From 9a2784e8f6e9f79e450ac2e31aa5c3cb61e79b9e Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 12 Mar 2013 12:49:19 +0100 Subject: [PATCH] Fix bug in upnp string compare function --- coreapi/upnp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/coreapi/upnp.c b/coreapi/upnp.c index 596afe33..e8841c2d 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -111,22 +111,24 @@ void linphone_upnp_config_remove_port_binding(UpnpContext *lupnp, const UpnpPort int linphone_upnp_context_send_remove_port_binding(UpnpContext *lupnp, UpnpPortBinding *port, bool_t retry); int linphone_upnp_context_send_add_port_binding(UpnpContext *lupnp, UpnpPortBinding *port, bool_t retry); - static int linphone_upnp_strncmpi(const char *str1, const char *str2, int len) { int i = 0; char char1, char2; - while(*str1 != '\0' && *str2 != '\0' && i < len) { + while(true) { + if(i >= len) { + return 0; + } char1 = toupper(*str1); char2 = toupper(*str2); - if(char1 != char2) { + if(char1 == '\0' || char2 == '\0' || char1 != char2) { return char1 - char2; } str1++; str2++; - len++; + i++; } - return 0; } + static int linphone_upnp_str_min(const char *str1, const char *str2) { int len1 = strlen(str1); int len2 = strlen(str2); @@ -135,6 +137,7 @@ static int linphone_upnp_str_min(const char *str1, const char *str2) { } return len1; } + char * linphone_upnp_format_device_id(const char *device_id) { char *ret = NULL; char *tmp; -- 2.39.2