Skip to contentSkip to conversation

rt-migrate-test: increase the buf size to 2048 when parse cpuinfo

PATCH In review Liwei Song 2 participants 2 messages Feb 14, 2022 – Feb 15, 2022

lore
Share & tools
lore

Liwei Song

author
#0 lore raw

PATCH 1/1 rt-migrate-test: increase the buf size to 2048 when parse cpuinfo

When parse /proc/cpuinfo, the size of "flags" may exceed 1024, this will cause "realloc(): invalid next size" error, increase the buf size to 2048 to fix this case.

---
 src/rt-migrate-test/rt-migrate-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/rt-migrate-test/rt-migrate-test.c +2 -2
index 62cc603c983b..883e60e21bff 100644
@@ -497,14 +497,14 @@ static void stop_log(int sig)
 static int count_cpus(void)
 {
 	FILE *fp;
-	char buf[1024];
+	char buf[2048];
 	int cpus = 0;
 	char *pbuf;
 	size_t *pn;
 	size_t n;
 	int r;
 
-	n = 1024;
+	n = 2048;
 	pn = &n;
 	pbuf = buf;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 32 lines · Liwei Song

When parse /proc/cpuinfo, the size of "flags" may exceed 1024, this will cause "realloc(): invalid next size" error, increase the buf size to 2048 to fix this case.

---
 src/rt-migrate-test/rt-migrate-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/rt-migrate-test/rt-migrate-test.c +2 -2
index 62cc603c983b..883e60e21bff 100644
@@ -497,14 +497,14 @@ static void stop_log(int sig)
 static int count_cpus(void)
 {
 	FILE *fp;
-	char buf[1024];
+	char buf[2048];
 	int cpus = 0;
 	char *pbuf;
 	size_t *pn;
 	size_t n;
 	int r;
 
-	n = 1024;
+	n = 2048;
 	pn = &n;
 	pbuf = buf;
 
Signature · 1 line
2.17.1