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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
--- ./src/rdist.c.ORI 2012-06-12 07:35:16.000000000 +0200
+++ ./src/rdist.c 2012-06-12 07:49:18.000000000 +0200
@@ -62,8 +62,8 @@
char *distfile = NULL; /* Name of distfile to use */
int maxchildren = MAXCHILDREN; /* Max no of concurrent PIDs */
int nflag = 0; /* Say without doing */
-long min_freespace = 0; /* Min filesys free space */
-long min_freefiles = 0; /* Min filesys free # files */
+int64_t min_freespace = 0; /* Min filesys free space */
+int64_t min_freefiles = 0; /* Min filesys free # files */
FILE *fin = NULL; /* Input file pointer */
struct group *gr = NULL; /* Static area for getgrent */
char localmsglist[] = "stdout=all:notify=all:syslog=nerror,ferror";
@@ -109,6 +109,7 @@
register char *cp;
int cmdargs = 0;
int c;
+ const char *errstr;
/*
* We initialize progname here instead of init() because
@@ -178,10 +179,20 @@
error("\"%s\" is not a number.", optarg);
usage();
}
- if (c == 'a')
- min_freespace = atoi(optarg);
- else if (c == 'A')
- min_freefiles = atoi(optarg);
+ if (c == 'a') {
+ min_freespace = (int64_t)strtonum(optarg,
+ 0, LLONG_MAX, &errstr);
+ if (errstr)
+ fatalerr("Minimum free space is %s: "
+ "'%s'", errstr, optarg);
+ }
+ else if (c == 'A') {
+ min_freefiles = (int64_t)strtonum(optarg,
+ 0, LLONG_MAX, &errstr);
+ if (errstr)
+ fatalerr("Minimum free files is %s: "
+ "'%s'", errstr, optarg);
+ }
else if (c == 'M')
maxchildren = atoi(optarg);
else if (c == 't')
--- ./src/server.c.ORI 2012-06-12 07:35:16.000000000 +0200
+++ ./src/server.c 2012-06-12 08:14:41.651950502 +0200
@@ -62,8 +62,8 @@
int catname = 0; /* cat name to target name */
char *sptarget[32]; /* stack of saved ptarget's for directories */
char *fromhost = NULL; /* Client hostname */
-static long min_freespace = 0; /* Minimium free space on a filesystem */
-static long min_freefiles = 0; /* Minimium free # files on a filesystem */
+static int64_t min_freespace = 0; /* Minimium free space on a filesystem */
+static int64_t min_freefiles = 0; /* Minimium free # files on a filesystem */
int oumask; /* Old umask */
/*
@@ -645,8 +645,8 @@
case S_IFLNK:
case S_IFDIR:
case S_IFREG:
- (void) sendcmd(QC_YES, "%ld %ld %o %s %s",
- (long) stb.st_size,
+ (void) sendcmd(QC_YES, "%lld %ld %o %s %s",
+ (long long) stb.st_size,
stb.st_mtime,
stb.st_mode & 07777,
getusername(stb.st_uid, target, options),
@@ -783,13 +783,13 @@
wrerr = 0;
olderrno = 0;
for (i = 0; i < size; i += BUFSIZ) {
- int amt = BUFSIZ;
+ off_t amt = BUFSIZ;
cp = buf;
if (i + amt > size)
amt = size - i;
do {
- int j;
+ ssize_t j;
j = readrem(cp, amt);
if (j <= 0) {
@@ -1306,6 +1306,7 @@
{
register char *cp = cmd;
char *estr;
+ const char *errstr;
switch (*cp++) {
case SC_HOSTNAME: /* Set hostname */
@@ -1322,19 +1323,15 @@
break;
case SC_FREESPACE: /* Minimium free space */
- if (!isdigit(*cp)) {
- fatalerr("Expected digit, got '%s'.", cp);
- return;
- }
- min_freespace = (unsigned long) atoi(cp);
+ min_freespace = (int64_t)strtonum(cp, 0, LLONG_MAX, &errstr);
+ if (errstr)
+ fatalerr("Minimum free space is %s: '%s'", errstr, optarg);
break;
case SC_FREEFILES: /* Minimium free files */
- if (!isdigit(*cp)) {
- fatalerr("Expected digit, got '%s'.", cp);
- return;
- }
- min_freefiles = (unsigned long) atoi(cp);
+ min_freefiles = (int64_t)strtonum(cp, 0, LLONG_MAX, &errstr);
+ if (errstr)
+ fatalerr("Minimum free files is %s: '%s'", errstr, optarg);
break;
case SC_LOGGING: /* Logging options */
@@ -1364,7 +1361,7 @@
time_t mtime, atime;
char *owner, *group, *file;
char new[MAXPATHLEN];
- long freespace = -1, freefiles = -1;
+ int64_t freespace = -1, freefiles = -1;
char *cp = cmd;
/*
@@ -1388,7 +1385,7 @@
/*
* Get file size
*/
- size = strtol(cp, &cp, 10);
+ size = (off_t) strtoll(cp, &cp, 10);
if (*cp++ != ' ') {
error("recvit: size not delimited");
return;
@@ -1397,7 +1394,7 @@
/*
* Get modification time
*/
- mtime = strtol(cp, &cp, 10);
+ mtime = (time_t) strtol(cp, &cp, 10);
if (*cp++ != ' ') {
error("recvit: mtime not delimited");
return;
@@ -1441,8 +1438,8 @@
}
debugmsg(DM_MISC,
- "recvit: opts = %04o mode = %04o size = %d mtime = %d",
- opts, mode, size, mtime);
+ "recvit: opts = %04o mode = %04o size = %lld mtime = %d",
+ opts, mode, (long long) size, mtime);
debugmsg(DM_MISC,
"recvit: owner = '%s' group = '%s' file = '%s' catname = %d isdir = %d",
owner, group, file, catname, (type == S_IFDIR) ? 1 : 0);
@@ -1486,7 +1483,7 @@
*/
if (min_freespace || min_freefiles) {
/* Convert file size to kilobytes */
- long fsize = (long) (size / 1024);
+ int64_t fsize = (int64_t)size / 1024;
if (getfilesysinfo(target, &freespace, &freefiles) != 0)
return;
@@ -1498,15 +1495,15 @@
if (min_freespace && (freespace >= 0) &&
(freespace - fsize < min_freespace)) {
error(
- "%s: Not enough free space on filesystem: min %d free %d",
- target, min_freespace, freespace);
+ "%s: Not enough free space on filesystem: min %lld "
+ "free %lld", target, min_freespace, freespace);
return;
}
if (min_freefiles && (freefiles >= 0) &&
(freefiles - 1 < min_freefiles)) {
error(
- "%s: Not enough free files on filesystem: min %d free %d",
- target, min_freefiles, freefiles);
+ "%s: Not enough free files on filesystem: min %lld free "
+ "%lld", target, min_freefiles, freefiles);
return;
}
}
--- ./src/docmd.c.ORI 2012-06-12 07:35:16.000000000 +0200
+++ ./src/docmd.c 2012-06-12 08:11:29.000000000 +0200
@@ -102,7 +102,8 @@
register struct namelist *to;
time_t lmod;
{
- register int fd, len;
+ register int fd;
+ ssize_t len;
FILE *pf, *popen();
struct stat stb;
static char buf[BUFSIZ];
@@ -325,7 +326,7 @@
register char *ruser, *cp;
static char *cur_host = NULL;
extern char *locuser;
- extern long min_freefiles, min_freespace;
+ extern int64_t min_freefiles, min_freespace;
extern char *remotemsglist;
char tuser[BUFSIZ], buf[BUFSIZ];
u_char respbuff[BUFSIZ];
@@ -416,13 +417,13 @@
return(0);
}
if (min_freespace) {
- (void) sendcmd(C_SETCONFIG, "%c%d", SC_FREESPACE,
+ (void) sendcmd(C_SETCONFIG, "%c%lld", SC_FREESPACE,
min_freespace);
if (response() < 0)
return(0);
}
if (min_freefiles) {
- (void) sendcmd(C_SETCONFIG, "%c%d", SC_FREEFILES,
+ (void) sendcmd(C_SETCONFIG, "%c%lld", SC_FREEFILES,
min_freefiles);
if (response() < 0)
return(0);
--- ./src/common.c.ORI 2012-06-12 07:35:16.000000000 +0200
+++ ./src/common.c 2012-06-12 08:01:34.000000000 +0200
@@ -379,14 +379,14 @@
*/
static u_char rembuf[BUFSIZ];
static u_char *remptr;
-static int remleft;
+static ssize_t remleft;
#define remc() (--remleft < 0 ? remmore() : *remptr++)
/*
* Back end to remote read()
*/
-static int remread(fd, buf, bufsiz)
+static ssize_t remread(fd, buf, bufsiz)
int fd;
u_char *buf;
int bufsiz;
@@ -480,7 +480,7 @@
/*
* Non-line-oriented remote read.
*/
-readrem(p, space)
+ssize_t readrem(p, space)
char *p;
register int space;
{
@@ -878,7 +878,7 @@
extern POINTER *malloc();
if ((ptr = (char *)malloc(amt)) == NULL)
- fatalerr("Cannot malloc %d bytes of memory.", amt);
+ fatalerr("Cannot malloc %zu bytes of memory.", amt);
return(ptr);
}
@@ -894,7 +894,7 @@
extern POINTER *realloc();
if ((new = (char *)realloc(baseptr, amt)) == NULL)
- fatalerr("Cannot realloc %d bytes of memory.", amt);
+ fatalerr("Cannot realloc %zu bytes of memory.", amt);
return(new);
}
@@ -910,7 +910,7 @@
extern POINTER *calloc();
if ((ptr = (char *)calloc(num, esize)) == NULL)
- fatalerr("Cannot calloc %d * %d = %d bytes of memory.",
+ fatalerr("Cannot calloc %zu * %zu = %zu bytes of memory.",
num, esize, num * esize);
return(ptr);
--- ./src/filesys.c.ORI 2012-06-12 07:35:16.000000000 +0200
+++ ./src/filesys.c 2012-06-12 08:12:20.000000000 +0200
@@ -434,8 +434,8 @@
*/
int getfilesysinfo(file, freespace, freefiles)
char *file;
- long *freespace;
- long *freefiles;
+ int64_t *freespace;
+ int64_t *freefiles;
{
#if defined(STATFS_TYPE)
static statfs_t statfsbuf;
--- ./config/config-data.h.ORI 1998-11-10 04:59:47.000000000 +0100
+++ ./config/config-data.h 2012-06-12 07:55:48.000000000 +0200
@@ -58,10 +58,10 @@
* Set default write(2) return and amount types.
*/
#if !defined(WRITE_RETURN_T)
-#define WRITE_RETURN_T int /* What write() returns */
+#define WRITE_RETURN_T ssize_t /* What write() returns */
#endif /* WRITE_RETURN_T */
#if !defined(WRITE_AMT_T)
-#define WRITE_AMT_T int /* Amount to write */
+#define WRITE_AMT_T size_t /* Amount to write */
#endif /* WRITE_AMT_T */
#endif /* __configdata_h__ */
--- ./src/client.c.ORI 2012-06-12 08:26:35.000000000 +0200
+++ ./src/client.c 2012-06-12 08:57:34.000000000 +0200
@@ -399,9 +399,9 @@
/*
* Send file info
*/
- (void) sendcmd(C_RECVREG, "%o %04o %ld %ld %ld %s %s %s",
+ (void) sendcmd(C_RECVREG, "%o %04o %lld %ld %ld %s %s %s",
opts, stb->st_mode & 07777,
- (long) stb->st_size,
+ (long long) stb->st_size,
stb->st_mtime, stb->st_atime,
user, group, rname);
if (response() < 0) {
@@ -409,8 +409,8 @@
return(-1);
}
- debugmsg(DM_MISC, "Send file '%s' %d bytes\n",
- rname, (long) stb->st_size);
+ debugmsg(DM_MISC, "Send file '%s' %ld bytes\n",
+ rname, (long long) stb->st_size);
/*
* Set remote time out alarm handler.
@@ -661,9 +661,9 @@
/*
* Gather and send basic link info
*/
- (void) sendcmd(C_RECVSYMLINK, "%o %04o %ld %ld %ld %s %s %s",
+ (void) sendcmd(C_RECVSYMLINK, "%o %04o %lld %ld %ld %s %s %s",
opts, stb->st_mode & 07777,
- (long) stb->st_size,
+ (long long) stb->st_size,
stb->st_mtime, stb->st_atime,
user, group, rname);
if (response() < 0)
@@ -843,7 +843,7 @@
/*
* Parse size
*/
- size = strtol(cp, &cp, 10);
+ size = strtoll(cp, &cp, 10);
if (*cp++ != ' ') {
error("update: size not delimited");
return(US_NOTHING);
@@ -895,8 +895,8 @@
debugmsg(DM_MISC, "update(%s,) local mode %04o remote mode %04o\n",
rname, lmode, rmode);
- debugmsg(DM_MISC, "update(%s,) size %d mtime %d owner '%s' grp '%s'\n",
- rname, (int) size, mtime, owner, group);
+ debugmsg(DM_MISC, "update(%s,) size %lld mtime %d owner '%s' grp '%s'\n",
+ rname, (long long) size, mtime, owner, group);
if (statp->st_mtime != mtime) {
if (statp->st_mtime < mtime && IS_ON(opts, DO_YOUNGER)) {
@@ -922,8 +922,8 @@
}
if (statp->st_size != size) {
- debugmsg(DM_MISC, "size does not match (%d != %d).\n",
- (int) statp->st_size, size);
+ debugmsg(DM_MISC, "size does not match (%lld != %lld).\n",
+ (long long) statp->st_size, (long long)size);
return(US_OUTDATE);
}
--- ./src/child.c.ORI 1998-11-10 05:18:57.000000000 +0100
+++ ./src/child.c 2012-06-12 08:58:16.000000000 +0200
@@ -189,7 +189,7 @@
CHILD *child;
{
char rbuf[BUFSIZ];
- int amt;
+ ssize_t amt;
debugmsg(DM_CALL, "[readchild(%s, %d, %d) start]",
child->c_name, child->c_pid, child->c_readfd);
@@ -208,7 +208,7 @@
*/
while ((amt = read(child->c_readfd, rbuf, sizeof(rbuf))) > 0) {
/* XXX remove these debug calls */
- debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %d bytes]",
+ debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %lld bytes]",
child->c_name, child->c_pid, child->c_readfd, amt);
(void) xwrite(fileno(stdout), rbuf, amt);
@@ -217,7 +217,7 @@
child->c_name, child->c_pid, child->c_readfd);
}
- debugmsg(DM_MISC, "readchild(%s, %d, %d) done: amt = %d errno = %d\n",
+ debugmsg(DM_MISC, "readchild(%s, %d, %d) done: amt = %lld errno = %d\n",
child->c_name, child->c_pid, child->c_readfd, amt, errno);
/*
|