mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-02 22:06:10 +00:00
Fix parseSdpAttributeTo[U]Int() to avoid writing to the const input string
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user