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