qubes-restore: guard against falling off the start of the buffer

This commit is contained in:
Vincent Penquerc'h 2013-12-30 09:19:46 -05:00 committed by Marek Marczykowski-Górecki
parent f34728c0bb
commit 67c198552b

View File

@ -226,9 +226,9 @@ char *get_vmname_from_savefile(int fd)
} }
*name = 0; *name = 0;
slash = name - 1; slash = name - 1;
while (slash[0] && slash[0] != '/') while (slash >= buf && slash[0] && slash[0] != '/')
slash--; slash--;
if (!*slash) { if (slash < buf || !*slash) {
fprintf(stderr, "cannot find / in savefile\n"); fprintf(stderr, "cannot find / in savefile\n");
exit(1); exit(1);
} }