Fix parseSdpAttributeTo[U]Int() to avoid writing to the const input string
This commit is contained in:
parent
b2497a3918
commit
116267a245
1 changed files with 2 additions and 20 deletions
|
|
@ -722,17 +722,8 @@ bool parseSdpAttributeToUInt(const char* payload, const char* name, unsigned int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate the end of the value
|
// Read the integer up to the newline at the end of the SDP attribute
|
||||||
char* valend;
|
|
||||||
if (!(valend = strstr(valst, "\r")) && !(valend = strstr(valst, "\n"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swap the end character for a null terminator, read the integer, then swap it back
|
|
||||||
char valendchar = *valend;
|
|
||||||
*valend = 0;
|
|
||||||
*val = strtoul(valst + 1, NULL, 0);
|
*val = strtoul(valst + 1, NULL, 0);
|
||||||
*valend = valendchar;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -750,17 +741,8 @@ bool parseSdpAttributeToInt(const char* payload, const char* name, int* val) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate the end of the value
|
// Read the integer up to the newline at the end of the SDP attribute
|
||||||
char* valend;
|
|
||||||
if (!(valend = strstr(valst, "\r")) && !(valend = strstr(valst, "\n"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swap the end character for a null terminator, read the integer, then swap it back
|
|
||||||
char valendchar = *valend;
|
|
||||||
*valend = 0;
|
|
||||||
*val = strtol(valst + 1, NULL, 0);
|
*val = strtol(valst + 1, NULL, 0);
|
||||||
*valend = valendchar;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue