From: notaz <notasas@gmail.com>
Date: Sat, 30 Sep 2023 19:43:03 +0000 (+0300)
Subject: psxbios: more careful cnf parsing
X-Git-Tag: r24~135
X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc3178e9ced416632e8b5b5486bb35a561a6b2b9;p=pcsx_rearmed.git

psxbios: more careful cnf parsing
---

diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c
index da1dbea8..d748ac07 100644
--- a/libpcsxcore/misc.c
+++ b/libpcsxcore/misc.c
@@ -22,6 +22,7 @@
 */
 
 #include <stddef.h>
+#include <errno.h>
 #include <assert.h>
 #include "misc.h"
 #include "cdrom.h"
@@ -174,8 +175,13 @@ static void getFromCnf(char *buf, const char *key, u32 *val)
 	buf = strstr(buf, key);
 	if (buf)
 		buf = strchr(buf, '=');
-	if (buf)
-		*val = strtol(buf + 1, NULL, 16);
+	if (buf) {
+		unsigned long v;
+		errno = 0;
+		v = strtoul(buf + 1, NULL, 16);
+		if (errno == 0)
+			*val = v;
+	}
 }
 
 int LoadCdrom() {