mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
12845: dynamically allocate pbuf in domove()
This commit is contained in:
parent
2909b28776
commit
3ce3caeec6
2 changed files with 17 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2000-09-19 Clint Adams <schizo@debian.org>
|
||||||
|
|
||||||
|
* 12845: Src/Modules/files.c: dynamically allocate pbuf in domove().
|
||||||
|
|
||||||
2000-09-18 Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
|
2000-09-18 Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
|
||||||
|
|
||||||
* 12835: Doc/Zsh/compwid.yo: Alphabetize list of special parameters
|
* 12835: Doc/Zsh/compwid.yo: Alphabetize list of special parameters
|
||||||
|
|
|
@ -255,14 +255,15 @@ static int
|
||||||
domove(char *nam, MoveFunc move, char *p, char *q, int flags)
|
domove(char *nam, MoveFunc move, char *p, char *q, int flags)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *qbuf;
|
char *pbuf, *qbuf;
|
||||||
char pbuf[PATH_MAX + 1];
|
|
||||||
strcpy(pbuf, unmeta(p));
|
pbuf = ztrdup(unmeta(p));
|
||||||
qbuf = unmeta(q);
|
qbuf = unmeta(q);
|
||||||
if(flags & MV_NODIRS) {
|
if(flags & MV_NODIRS) {
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
if(lstat(pbuf, &st) || S_ISDIR(st.st_mode)) {
|
if(lstat(pbuf, &st) || S_ISDIR(st.st_mode)) {
|
||||||
zwarnnam(nam, "%s: %e", p, errno);
|
zwarnnam(nam, "%s: %e", p, errno);
|
||||||
|
zsfree(pbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,6 +271,7 @@ domove(char *nam, MoveFunc move, char *p, char *q, int flags)
|
||||||
int doit = flags & MV_FORCE;
|
int doit = flags & MV_FORCE;
|
||||||
if(S_ISDIR(st.st_mode)) {
|
if(S_ISDIR(st.st_mode)) {
|
||||||
zwarnnam(nam, "%s: cannot overwrite directory", q, 0);
|
zwarnnam(nam, "%s: cannot overwrite directory", q, 0);
|
||||||
|
zsfree(pbuf);
|
||||||
return 1;
|
return 1;
|
||||||
} else if(flags & MV_INTER) {
|
} else if(flags & MV_INTER) {
|
||||||
nicezputs(nam, stderr);
|
nicezputs(nam, stderr);
|
||||||
|
@ -277,8 +279,10 @@ domove(char *nam, MoveFunc move, char *p, char *q, int flags)
|
||||||
nicezputs(q, stderr);
|
nicezputs(q, stderr);
|
||||||
fputs("'? ", stderr);
|
fputs("'? ", stderr);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
if(!ask())
|
if(!ask()) {
|
||||||
|
zsfree(pbuf);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
doit = 1;
|
doit = 1;
|
||||||
} else if((flags & MV_ASKNW) &&
|
} else if((flags & MV_ASKNW) &&
|
||||||
!S_ISLNK(st.st_mode) &&
|
!S_ISLNK(st.st_mode) &&
|
||||||
|
@ -289,8 +293,10 @@ domove(char *nam, MoveFunc move, char *p, char *q, int flags)
|
||||||
fprintf(stderr, "', overriding mode %04o? ",
|
fprintf(stderr, "', overriding mode %04o? ",
|
||||||
mode_to_octal(st.st_mode));
|
mode_to_octal(st.st_mode));
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
if(!ask())
|
if(!ask()) {
|
||||||
|
zsfree(pbuf);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
doit = 1;
|
doit = 1;
|
||||||
}
|
}
|
||||||
if(doit && !(flags & MV_ATOMIC))
|
if(doit && !(flags & MV_ATOMIC))
|
||||||
|
@ -298,8 +304,10 @@ domove(char *nam, MoveFunc move, char *p, char *q, int flags)
|
||||||
}
|
}
|
||||||
if(move(pbuf, qbuf)) {
|
if(move(pbuf, qbuf)) {
|
||||||
zwarnnam(nam, "%s: %e", p, errno);
|
zwarnnam(nam, "%s: %e", p, errno);
|
||||||
|
zsfree(pbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
zsfree(pbuf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue