miniupnpc.c: dont break if USN is not set

USN is mandatory, but don't break if the packet don't follow the standard and misses USN: header
This commit is contained in:
Thomas Bernard 2015-07-22 23:46:44 +02:00
parent bfc7c4f042
commit 963eefcae5
1 changed files with 5 additions and 4 deletions

View File

@ -701,17 +701,17 @@ upnpDiscoverDevices(const char * const deviceTypes[],
const char * usn=NULL;
int usnsize=0;
parseMSEARCHReply(bufr, n, &descURL, &urlsize, &st, &stsize, &usn, &usnsize);
if(st&&descURL&&usn) {
if(st&&descURL) {
#ifdef DEBUG
printf("M-SEARCH Reply:\n ST: %.*s\n USN: %.*s\n Location: %.*s\n",
stsize, st, usnsize, usn, urlsize, descURL);
stsize, st, usnsize, (usn?usn:""), urlsize, descURL);
#endif /* DEBUG */
for(tmp=devlist; tmp; tmp = tmp->pNext) {
if(memcmp(tmp->descURL, descURL, urlsize) == 0 &&
tmp->descURL[urlsize] == '\0' &&
memcmp(tmp->st, st, stsize) == 0 &&
tmp->st[stsize] == '\0' &&
memcmp(tmp->usn, usn, usnsize) == 0 &&
(usnsize == 0 || memcmp(tmp->usn, usn, usnsize) == 0) &&
tmp->usn[usnsize] == '\0')
break;
}
@ -734,7 +734,8 @@ upnpDiscoverDevices(const char * const deviceTypes[],
tmp->buffer[urlsize] = '\0';
memcpy(tmp->st, st, stsize);
tmp->buffer[urlsize+1+stsize] = '\0';
memcpy(tmp->usn, usn, usnsize);
if(usn != NULL)
memcpy(tmp->usn, usn, usnsize);
tmp->buffer[urlsize+1+stsize+1+usnsize] = '\0';
tmp->scope_id = scope_id;
devlist = tmp;