Hello,
attached is a patch for fixing a small bug which makes
get_remote_audio_port_media overwrite other things if received SDP does
not contain \r\n right after the port number. The attached patch doesn't
make it a proper SDP parser either, but it should be safer with it (and
doesn't crash).
Stefan
--
Stefan Sayer
Media Services Development
iptego GmbH
Am Borsigturm 40
13507 Berlin
Germany
[EMAIL PROTECTED]
www.iptego.de
Index: call.cpp
===================================================================
--- call.cpp (revision 149)
+++ call.cpp (working copy)
@@ -449,6 +449,20 @@
return 1;
}
+char* str_n_get_first_of(char* haystack, unsigned int nmax, char* needles) {
+ char* p = haystack;
+ while (p < haystack + nmax) {
+ char* n = needles;
+ while(*n) {
+ if(*n == *p)
+ return p;
+ n++;
+ }
+ p++;
+ }
+ return NULL;
+}
+
/*
* Look for "m=audio " pattern in the message and extract the following value
* which should be port number
@@ -459,16 +473,19 @@
char *begin, *end;
char number[5];
begin = strstr(msg, pattern);
- if (!begin) {
- /* m=audio not found */
- return 0;
- }
+ if (!begin)
+ ERROR("get_remote_audio_port_media: No audio media port found in SDP");
begin += sizeof("m=audio ") - 1;
- end = strstr(begin, "\r\n");
- if (!end)
+ end = str_n_get_first_of(begin, 5, " \t\r\n");
+
+ if (!end) {
ERROR("get_remote_audio_port_media: no CRLF found");
+ return 0;
+ }
memset(number, 0, 5);
- strncpy(number, begin, end - begin);
+ strncpy(number, begin, end - begin);
+ fprintf(stderr, "got media port %d\n", atoi(number));
+
return atoi(number);
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sipp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sipp-users