miniupnpd/minissdp.c: Fix submission of services to minissdpd

Version was hardcoded to 1 in "ST:"
This commit is contained in:
Thomas Bernard 2018-02-03 18:14:31 +01:00
parent ab689d5893
commit 7f17837253
1 changed files with 14 additions and 10 deletions

View File

@ -1496,20 +1496,23 @@ SubmitServicesToMiniSSDPD(const char * host, unsigned short port) {
}
for(i = 0; known_service_types[i].s; i++) {
buffer[0] = 4; /* request type 4 : submit service */
/* 4 strings following : ST (service type), USN, Server, Location */
p = buffer + 1;
l = (int)strlen(known_service_types[i].s);
if(i > 0)
l++;
CODELENGTH(l, p);
memcpy(p, known_service_types[i].s, l);
if(i > 0)
p[l-1] = '1';
p += l;
if(i==0)
ver_str[0] = '\0';
else
snprintf(ver_str, sizeof(ver_str), "%d", known_service_types[i].version);
/* 4 strings following : ST (service type), USN, Server, Location */
p = buffer + 1;
l = snprintf(strbuf, sizeof(strbuf), "%s%s",
known_service_types[i].s, ver_str);
if(l<0) {
syslog(LOG_WARNING, "SubmitServicesToMiniSSDPD: snprintf %m");
continue;
} else if((unsigned)l>=sizeof(strbuf)) {
l = sizeof(strbuf) - 1;
}
CODELENGTH(l, p);
memcpy(p, strbuf, l);
p += l;
l = snprintf(strbuf, sizeof(strbuf), "%s::%s%s",
known_service_types[i].uuid, known_service_types[i].s, ver_str);
if(l<0) {
@ -1557,6 +1560,7 @@ SubmitServicesToMiniSSDPD(const char * host, unsigned short port) {
}
}
close(s);
syslog(LOG_DEBUG, "%d service submitted to MiniSSDPd", i);
return 0;
}