summaryrefslogtreecommitdiff
path: root/net/rdist6/patches/patch-ai
blob: e8c799f54509ef1bfe49c03ebffaec0603484fad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
$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)