ape/mv: check if from path fits and error if too long
This commit is contained in:
parent
b4e34c1c74
commit
4ae38efc1c
1 changed files with 7 additions and 1 deletions
|
@ -85,7 +85,13 @@ mv1(char *from, Dir *dirb, char *todir, char *toelem)
|
|||
char *fromdir, *fromelem;
|
||||
Dir *dirt, null;
|
||||
|
||||
strncpy(fromname, from, sizeof fromname);
|
||||
i = strlen(from);
|
||||
if(i >= sizeof(fromname)){
|
||||
fprint(2, "mv: path too big (max %d): %s\n",
|
||||
sizeof(fromname), from);
|
||||
return -1;
|
||||
}
|
||||
memmove(fromname, from, i+1);
|
||||
split(from, &fromdir, &fromelem);
|
||||
if(toelem == 0)
|
||||
toelem = fromelem;
|
||||
|
|
Loading…
Reference in a new issue