mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 04:56:31 +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:
parent
22b67bfa96
commit
91d9cab6de
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user