Unverified Commit 91d9cab6 by 2xsec

utils: defensive programming

If caller passed the size of array not string length, it is possible to be accessed out of bounds. Reorder conditions can prevent access invalid index of array. Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent 22b67bfa
...@@ -898,10 +898,10 @@ static char *get_nextpath(char *path, int *offsetp, int fulllen) ...@@ -898,10 +898,10 @@ static char *get_nextpath(char *path, int *offsetp, int fulllen)
if (offset >= fulllen) if (offset >= fulllen)
return NULL; return NULL;
while (path[offset] != '\0' && offset < fulllen) while (offset < fulllen && path[offset] != '\0')
offset++; offset++;
while (path[offset] == '\0' && offset < fulllen) while (offset < fulllen && path[offset] == '\0')
offset++; offset++;
*offsetp = offset; *offsetp = offset;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment