pkgsrc/net/rdist6/patches/patch-ai
dholland f7ba04f1e4 Update lukem's earlier fixes to use intmax_t for printing/reading time_t
values, and also for (perhaps not all) off_t values. And while here, fix
an unrelated LP64 bug calling execl(). PKGREVISION -> 4.
2010-06-12 19:36:00 +00:00

90 lines
2.6 KiB
Text

$NetBSD: patch-ai,v 1.3 2010/06/12 19:36:01 dholland Exp $
Print and parse time_t as intmax_t, not as long (which might not fit).
Likewise for (perhaps only some uses of) off_t.
The last hunk is unrelated to the rest and fixes a tilde expansion bug.
--- src/server.c.orig 1999-08-04 15:57:33.000000000 +0000
+++ src/server.c
@@ -683,8 +683,8 @@ static void query(xname)
case S_IFIFO:
#endif
#endif
- (void) sendcmd(QC_YES, "%ld %ld %o %s %s",
- (long) stb.st_size, stb.st_mtime,
+ (void) sendcmd(QC_YES, "%jd %jd %o %s %s",
+ (intmax_t)stb.st_size, (intmax_t)stb.st_mtime,
stb.st_mode & 07777,
getusername(stb.st_uid, target, options),
getgroupname(stb.st_gid, target, options));
@@ -1449,6 +1449,7 @@ static void recvit(cmd, type)
opt_t opts;
off_t size;
time_t mtime, atime;
+ intmax_t size_big, mtime_big, atime_big;
char *owner, *group, *file;
char new[MAXPATHLEN];
char fileb[MAXPATHLEN];
@@ -1476,7 +1477,12 @@ static void recvit(cmd, type)
/*
* Get file size
*/
- size = strtol(cp, &cp, 10);
+ size_big = strtoimax(cp, &cp, 10);
+ if ((intmax_t)(off_t)size_big != size_big) {
+ error("recvit: size out of range");
+ return;
+ }
+ size = (off_t)size_big;
if (*cp++ != ' ') {
error("recvit: size not delimited");
return;
@@ -1485,7 +1491,12 @@ static void recvit(cmd, type)
/*
* Get modification time
*/
- mtime = strtol(cp, &cp, 10);
+ mtime_big = strtoimax(cp, &cp, 10);
+ if ((intmax_t)(off_t)mtime_big != mtime_big) {
+ error("recvit: mtime out of range");
+ return;
+ }
+ mtime = (time_t)mtime_big;
if (*cp++ != ' ') {
error("recvit: mtime not delimited");
return;
@@ -1494,7 +1505,12 @@ static void recvit(cmd, type)
/*
* Get access time
*/
- atime = strtol(cp, &cp, 10);
+ atime_big = strtoimax(cp, &cp, 10);
+ if ((intmax_t)(off_t)atime_big != atime_big) {
+ error("recvit: atime out of range");
+ return;
+ }
+ atime = (time_t)atime_big;
if (*cp++ != ' ') {
error("recvit: atime not delimited");
return;
@@ -1534,8 +1550,8 @@ static void recvit(cmd, type)
file = fileb;
debugmsg(DM_MISC,
- "recvit: opts = %04o mode = %04o size = %d mtime = %d",
- opts, mode, size, mtime);
+ "recvit: opts = %04o mode = %04o size = %jd mtime = %jd",
+ opts, mode, (intmax_t)size, (intmax_t)mtime);
debugmsg(DM_MISC,
"recvit: owner = '%s' group = '%s' file = '%s' catname = %d isdir = %d",
owner, group, file, catname, (type == S_IFDIR) ? 1 : 0);
@@ -1737,7 +1753,7 @@ static void settarget(cmd, isdir)
/*
* Handle target
*/
- if (exptilde(target, cp) == NULL)
+ if (exptilde(target, file) == NULL)
return;
ptarget = target;
while (*ptarget)