1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 21:44:11 +01:00

12836: bin_ln now independent of PATH_MAX

This commit is contained in:
Clint Adams 2000-09-18 17:29:07 +00:00
parent f77ca8b839
commit 7c7e1f97cb
2 changed files with 18 additions and 20 deletions

@ -1,3 +1,8 @@
2000-09-18 Clint Adams <schizo@debian.org>
* 2836: Src/Modules/files.c: use ztrdup()/appstr() in lieu of
statically-allocated buffer in bin_ln.
2000-09-18 Bart Schaefer <schaefer@zsh.org>
* 12833: Back out the zasprintf changes from 12814, they're not

@ -186,10 +186,10 @@ static int
bin_ln(char *nam, char **args, char *ops, int func)
{
MoveFunc move;
int flags, space, err = 0;
char **a, *ptr, *rp;
int flags, err = 0;
char **a, *ptr, *rp, *buf;
struct stat st;
char buf[PATH_MAX * 2 + 1];
size_t blen;
if(func == BIN_MV) {
@ -230,30 +230,23 @@ bin_ln(char *nam, char **args, char *ops, int func)
}
return domove(nam, move, args[0], args[1], flags);
havedir:
strcpy(buf, *a);
buf = ztrdup(*a);
*a = NULL;
space = PATH_MAX - 1 - ztrlen(buf);
rp = strchr(buf, 0);
*rp++ = '/';
buf = appstr(buf, "/");
blen = strlen(buf);
for(; *args; args++) {
if(ztrlen(*args) > PATH_MAX) {
zwarnnam(nam, "%s: %e", *args, ENAMETOOLONG);
err = 1;
continue;
}
ptr = strrchr(*args, '/');
if(ptr)
ptr++;
else
ptr = *args;
if(ztrlen(ptr) > space) {
zwarnnam(nam, "%s: %e", ptr, ENAMETOOLONG);
err = 1;
continue;
}
strcpy(rp, ptr);
buf[blen] = 0;
buf = appstr(buf, ptr);
err |= domove(nam, move, *args, buf, flags);
}
zsfree(buf);
return err;
}