-/* $OpenBSD: ftpd.c,v 1.217 2016/07/04 03:24:48 guenther Exp $ */
+/* $OpenBSD: ftpd.c,v 1.218 2016/08/14 22:56:29 guenther Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
*(file2) == '/' ? "" : curdir(), file2);
#define LOGBYTES(cmd, file, cnt) \
if (logging > 1) { \
- if (cnt == (off_t)-1) \
+ if ((cnt) == -1) \
syslog(LOG_INFO,"%s %s%s", cmd, \
*(file) == '/' ? "" : curdir(), file); \
else \
- syslog(LOG_INFO, "%s %s%s = %qd bytes", \
- cmd, (*(file) == '/') ? "" : curdir(), file, cnt); \
+ syslog(LOG_INFO, "%s %s%s = %lld bytes", \
+ cmd, (*(file) == '/') ? "" : curdir(), file, \
+ (long long)(cnt)); \
}
static void ack(char *);
flags |= LOGIN_SETUMASK;
else
(void) umask(defumask);
- if (setusercontext(lc, pw, (uid_t)0, flags) != 0) {
+ if (setusercontext(lc, pw, 0, flags) != 0) {
perror_reply(421, "Local resource failure: setusercontext");
syslog(LOG_NOTICE, "setusercontext: %m");
dologout(1);
/* open utmp before chroot */
if (doutmp) {
- memset((void *)&utmp, 0, sizeof(utmp));
+ memset(&utmp, 0, sizeof(utmp));
(void)time(&utmp.ut_time);
(void)strncpy(utmp.ut_name, pw->pw_name, sizeof(utmp.ut_name));
(void)strncpy(utmp.ut_host, remotehost, sizeof(utmp.ut_host));
if (dout == NULL)
goto done;
time(&start);
- send_data(fin, dout, (off_t)st.st_blksize, st.st_size,
+ send_data(fin, dout, st.st_blksize, st.st_size,
(restart_point == 0 && cmd == NULL && S_ISREG(st.st_mode)));
if ((cmd == NULL) && stats)
logxfer(name, byte_count, start);
* because we are changing from reading to
* writing.
*/
- if (fseek(fout, 0L, SEEK_CUR) < 0) {
+ if (fseek(fout, 0, SEEK_CUR) < 0) {
perror_reply(550, name);
goto done;
}
goto done;
}
}
- din = dataconn(name, (off_t)-1, "r");
+ din = dataconn(name, -1, "r");
if (din == NULL)
goto done;
if (receive_data(din, fout) == 0) {
file_size = size;
byte_count = 0;
- if (size != (off_t) -1) {
- (void) snprintf(sizebuf, sizeof(sizebuf), " (%qd bytes)",
- size);
+ if (size != -1) {
+ (void) snprintf(sizebuf, sizeof(sizebuf), " (%lld bytes)",
+ (long long)size);
} else
sizebuf[0] = '\0';
if (pdata >= 0) {
netfd = fileno(outstr);
filefd = fileno(instr);
- if (isreg && filesize < (off_t)16 * 1024 * 1024) {
+ if (isreg && filesize < 16 * 1024 * 1024) {
size_t fsize = (size_t)filesize;
if (fsize == 0) {
return(0);
}
- buf = mmap(0, fsize, PROT_READ, MAP_SHARED, filefd,
- (off_t)0);
+ buf = mmap(0, fsize, PROT_READ, MAP_SHARED, filefd, 0);
if (buf == MAP_FAILED) {
syslog(LOG_WARNING, "mmap(%llu): %m",
(unsigned long long)fsize);
}
if (strcmp(cp, "STAT\r\n") == 0) {
tmpline[0] = '\0';
- if (file_size != (off_t) -1)
- reply(213, "Status: %qd of %qd bytes transferred",
- byte_count, file_size);
+ if (file_size != -1)
+ reply(213, "Status: %lld of %lld bytes transferred",
+ (long long)byte_count, (long long)file_size);
else
- reply(213, "Status: %qd bytes transferred", byte_count);
+ reply(213, "Status: %lld bytes transferred",
+ (long long)byte_count);
}
}
if (S_ISREG(st.st_mode)) {
if (dout == NULL) {
- dout = dataconn("file list", (off_t)-1, "w");
+ dout = dataconn("file list", -1, "w");
if (dout == NULL)
goto out;
transflag++;
(fstatat(dirfd(dirp), dir->d_name, &st, 0) == 0 &&
S_ISREG(st.st_mode))) {
if (dout == NULL) {
- dout = dataconn("file list", (off_t)-1,
- "w");
+ dout = dataconn("file list", -1, "w");
if (dout == NULL)
goto out;
transflag++;
strvis(vpw, guest? guestpw : pw->pw_name, VIS_SAFE|VIS_NOSLASH);
len = snprintf(buf, sizeof(buf),
- "%.24s %lld %s %qd %s %c %s %c %c %s ftp %d %s %s\n",
+ "%.24s %lld %s %lld %s %c %s %c %c %s ftp %d %s %s\n",
ctime(&now), (long long)(now - start + (now == start)),
vremotehost, (long long)size, vpath,
((type == TYPE_A) ? 'a' : 'b'), "*" /* none yet */,