Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit ad48a32

Browse files
committed
Avoid returning random number while parsing route failed
In current code, while parsing route information from JSON failed. The found will be 0, and the hyper_parse_routes will not be invoked. In this case, the r_num will not be assigned and use a random value. This will crash the guest kernel without the commit: d43bd26b8562fe6c96ee762d96ceb65b9b6c067f Change-Id: I2dd321b078d33bd1c3b2864ba81110eef17c8cb4 Signed-off-by: Wei Chen <Wei.Chen@arm.com>
1 parent 782a124 commit ad48a32

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/parse.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,12 @@ int hyper_parse_setup_routes(struct hyper_route **routes, uint32_t *r_num, char
10231023
jsmntok_t *toks = NULL;
10241024
int found = 0;
10251025

1026+
/*
1027+
* If we could not find routes from JSON, we have to set r_num to 0,
1028+
* this will avid returning a random number for r_num.
1029+
*/
1030+
*r_num = 0;
1031+
10261032
realloc:
10271033
toks = realloc(toks, toks_num * sizeof(jsmntok_t));
10281034
if (toks == NULL) {

0 commit comments

Comments
 (0)