From 116267a24569ec610f4c9efa1048541022981040 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 6 Oct 2023 18:12:08 -0500 Subject: [PATCH] Fix parseSdpAttributeTo[U]Int() to avoid writing to the const input string --- src/RtspConnection.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/RtspConnection.c b/src/RtspConnection.c index 83a325e..d1fc3c7 100644 --- a/src/RtspConnection.c +++ b/src/RtspConnection.c @@ -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; }