mirror of
git://github.com/lxc/lxc
synced 2025-08-31 04:59:37 +00:00
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: 2xsec <dh48.jeong@samsung.com>
This commit is contained in:
@@ -898,10 +898,10 @@ static char *get_nextpath(char *path, int *offsetp, int fulllen)
|
||||
if (offset >= fulllen)
|
||||
return NULL;
|
||||
|
||||
while (path[offset] != '\0' && offset < fulllen)
|
||||
while (offset < fulllen && path[offset] != '\0')
|
||||
offset++;
|
||||
|
||||
while (path[offset] == '\0' && offset < fulllen)
|
||||
while (offset < fulllen && path[offset] == '\0')
|
||||
offset++;
|
||||
|
||||
*offsetp = offset;
|
||||
|
Reference in New Issue
Block a user