1 diff --git a/src/osdep/types.h b/src/osdep/types.h
2 index 9d0f282..2404ac0 100644
3 --- a/src/osdep/types.h
4 +++ b/src/osdep/types.h
9 +#if defined(HAVE_LONG_LONG) && !defined(LLONG_MAX)
11 +#define LLONG_MAX MAXLLONG
12 +#elif SIZEOF_LONG_LONG == 8
13 +#define LLONG_MAX 9223372036854775807LL
14 +#elif SIZEOF_LONG_LONG == 4
15 +#define LLONG_MAX LONG_MAX
20 +#if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T == SIZEOF_LONG_LONG
21 +#define OFFT_MAX LLONG_MAX
22 +#elif SIZEOF_OFF_T == SIZEOF_LONG
23 +#define OFFT_MAX LONG_MAX
24 +#elif SIZEOF_OFF_T == SIZEOF_INT
25 +#define OFFT_MAX INT_MAX
26 +#elif SIZEOF_OFF_T == SIZEOF_SHORT
27 +#define OFFT_MAX SHRT_MAX
33 typedef unsigned char uint16_t;
34 diff --git a/src/protocol/ftp/ftp.c b/src/protocol/ftp/ftp.c
35 index 87ec444..01e301b 100644
36 --- a/src/protocol/ftp/ftp.c
37 +++ b/src/protocol/ftp/ftp.c
38 @@ -1091,7 +1091,7 @@ display_dir_entry(struct cache_entry *cached, off_t *pos, int *tries,
39 add_to_string(&string, " 1 ftp ftp ");
41 if (ftp_info->size != FTP_SIZE_UNKNOWN) {
42 - add_format_to_string(&string, "%12lu ", ftp_info->size);
43 + add_format_to_string(&string, "%12" OFF_T_FORMAT " ", ftp_info->size);
45 add_to_string(&string, " - ");
47 diff --git a/src/protocol/ftp/parse.c b/src/protocol/ftp/parse.c
48 index b5caeba..be4326e 100644
49 --- a/src/protocol/ftp/parse.c
50 +++ b/src/protocol/ftp/parse.c
52 #define skip_nonspace_end(src, end) \
53 do { while ((src) < (end) && *(src) != ' ') (src)++; } while (0)
56 -parse_ftp_number(unsigned char **src, unsigned char *end, long from, long to)
58 +parse_ftp_number(unsigned char **src, unsigned char *end, off_t from, off_t to)
62 unsigned char *pos = *src;
64 for (; pos < end && isdigit(*pos); pos++)
65 @@ -104,7 +104,7 @@ parse_ftp_eplf_response(struct ftp_file_info *info, unsigned char *src, int len)
68 if (src >= pos) break;
69 - info->size = parse_ftp_number(&src, pos, 0, LONG_MAX);
70 + info->size = parse_ftp_number(&src, pos, 0, OFFT_MAX);
74 @@ -278,7 +278,7 @@ parse_ftp_unix_response(struct ftp_file_info *info, unsigned char *src, int len)
78 - info->size = parse_ftp_number(&src, pos, 0, LONG_MAX);
79 + info->size = parse_ftp_number(&src, pos, 0, OFFT_MAX);
83 @@ -543,7 +543,7 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len
84 memset(&mtime, 0, sizeof(mtime));
87 - mtime.tm_mon = parse_ftp_number(&src, end, 1, 12);
88 + mtime.tm_mon = (int) parse_ftp_number(&src, end, 1, 12);
89 if (src + 2 >= end || *src != '-')
92 @@ -587,7 +587,7 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len
94 } else if (isdigit(*src)) {
95 info->type = FTP_FILE_PLAINFILE;
96 - info->size = parse_ftp_number(&src, end, 0, LONG_MAX);
97 + info->size = parse_ftp_number(&src, end, 0, OFFT_MAX);
98 info->permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
101 diff --git a/src/protocol/ftp/parse.h b/src/protocol/ftp/parse.h
102 index e777398..18cfacd 100644
103 --- a/src/protocol/ftp/parse.h
104 +++ b/src/protocol/ftp/parse.h
105 @@ -19,7 +19,7 @@ struct ftp_file_info {
106 enum ftp_file_type type; /* File type */
107 struct string name; /* File name */
108 struct string symlink; /* Link to which file points */
109 - long size; /* File size. -1 if unknown. */
110 + off_t size; /* File size. -1 if unknown. */
111 time_t mtime; /* Modification time */
112 unsigned int local_time_zone:1; /* What format the mtime is in */
113 mode_t permissions; /* File permissions */