mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +02:00
12836: bin_ln now independent of PATH_MAX
This commit is contained in:
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>
|
2000-09-18 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
* 12833: Back out the zasprintf changes from 12814, they're not
|
* 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)
|
bin_ln(char *nam, char **args, char *ops, int func)
|
||||||
{
|
{
|
||||||
MoveFunc move;
|
MoveFunc move;
|
||||||
int flags, space, err = 0;
|
int flags, err = 0;
|
||||||
char **a, *ptr, *rp;
|
char **a, *ptr, *rp, *buf;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char buf[PATH_MAX * 2 + 1];
|
size_t blen;
|
||||||
|
|
||||||
|
|
||||||
if(func == BIN_MV) {
|
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);
|
return domove(nam, move, args[0], args[1], flags);
|
||||||
havedir:
|
havedir:
|
||||||
strcpy(buf, *a);
|
buf = ztrdup(*a);
|
||||||
*a = NULL;
|
*a = NULL;
|
||||||
space = PATH_MAX - 1 - ztrlen(buf);
|
buf = appstr(buf, "/");
|
||||||
rp = strchr(buf, 0);
|
blen = strlen(buf);
|
||||||
*rp++ = '/';
|
|
||||||
for(; *args; args++) {
|
for(; *args; args++) {
|
||||||
if(ztrlen(*args) > PATH_MAX) {
|
|
||||||
zwarnnam(nam, "%s: %e", *args, ENAMETOOLONG);
|
|
||||||
err = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ptr = strrchr(*args, '/');
|
ptr = strrchr(*args, '/');
|
||||||
if(ptr)
|
if(ptr)
|
||||||
ptr++;
|
ptr++;
|
||||||
else
|
else
|
||||||
ptr = *args;
|
ptr = *args;
|
||||||
if(ztrlen(ptr) > space) {
|
|
||||||
zwarnnam(nam, "%s: %e", ptr, ENAMETOOLONG);
|
buf[blen] = 0;
|
||||||
err = 1;
|
buf = appstr(buf, ptr);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
strcpy(rp, ptr);
|
|
||||||
err |= domove(nam, move, *args, buf, flags);
|
err |= domove(nam, move, *args, buf, flags);
|
||||||
}
|
}
|
||||||
|
zsfree(buf);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue