Fix parseSdpAttributeTo[U]Int() to avoid writing to the const input string

This commit is contained in:
Cameron Gutman
2023-10-06 18:12:08 -05:00
parent b2497a3918
commit 116267a245

View File

@@ -722,17 +722,8 @@ bool parseSdpAttributeToUInt(const char* payload, const char* name, unsigned int
return false;
}
// Locate the end of the value
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;
// Read the integer up to the newline at the end of the SDP attribute
*val = strtoul(valst + 1, NULL, 0);
*valend = valendchar;
return true;
}
@@ -750,17 +741,8 @@ bool parseSdpAttributeToInt(const char* payload, const char* name, int* val) {
return false;
}
// Locate the end of the value
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;
// Read the integer up to the newline at the end of the SDP attribute
*val = strtol(valst + 1, NULL, 0);
*valend = valendchar;
return true;
}