Make sure we pass the length - 1 to readlink, since it adds its own
NUL at the end of the path. Inspired by: OpenBSD's changes in this area by theo de raadt
This commit is contained in:
parent
205a8ea824
commit
c788c9b224
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36787
@ -107,7 +107,7 @@ printlink(name)
|
||||
int lnklen;
|
||||
char path[MAXPATHLEN + 1];
|
||||
|
||||
if ((lnklen = readlink(name, path, MAXPATHLEN)) == -1) {
|
||||
if ((lnklen = readlink(name, path, MAXPATHLEN - 1)) == -1) {
|
||||
warn("%s", name);
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: server.c,v 1.7 1998/04/06 06:18:32 charnier Exp $";
|
||||
"$Id: server.c,v 1.8 1998/04/20 06:20:24 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/wait.h>
|
||||
@ -473,7 +473,7 @@ sendf(rname, opts)
|
||||
(void) write(rem, buf, strlen(buf));
|
||||
if (response() < 0)
|
||||
return;
|
||||
sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size);
|
||||
sizerr = (readlink(target, buf, BUFSIZ - 1) != stb.st_size);
|
||||
(void) write(rem, buf, stb.st_size);
|
||||
if (debug)
|
||||
printf("readlink = %.*s\n", (int)stb.st_size, buf);
|
||||
@ -870,7 +870,7 @@ recvf(cmd, type)
|
||||
if (opts & COMPARE) {
|
||||
char tbuf[BUFSIZ];
|
||||
|
||||
if ((i = readlink(target, tbuf, BUFSIZ)) >= 0 &&
|
||||
if ((i = readlink(target, tbuf, BUFSIZ - 1)) >= 0 &&
|
||||
i == size && strncmp(buf, tbuf, size) == 0) {
|
||||
(void) unlink(new);
|
||||
ack();
|
||||
|
Loading…
Reference in New Issue
Block a user