diff --git a/ftpfs-ls.c b/ftpfs-ls.c
index 070430a..e221071 100644
--- a/ftpfs-ls.c
+++ b/ftpfs-ls.c
@@ -27,7 +27,7 @@ static int parse_dir_unix(const char *line,
long nlink = 1;
char user[33];
char group[33];
- long size;
+ unsigned long long size;
char month[4];
char day[3];
char year[6];
@@ -46,7 +46,7 @@ static int parse_dir_unix(const char *line,
"%lu" SPACES
"%32s" SPACES
"%32s" SPACES
- "%lu" SPACES
+ "%llu" SPACES
"%3s" SPACES
"%2s" SPACES
"%5s" "%*c"
@@ -57,7 +57,7 @@ static int parse_dir_unix(const char *line,
"%11s"
"%32s" SPACES
"%32s" SPACES
- "%lu" SPACES
+ "%llu" SPACES
"%3s" SPACES
"%2s" SPACES
"%5s" "%*c"
@@ -156,7 +156,7 @@ static int parse_dir_win(const char *line,
if (!strcmp(size, "
")) {
sbuf->st_mode |= S_IFDIR;
} else {
- int nsize = strtol(size, NULL, 0);
+ unsigned long long nsize = strtoull(size, NULL, 0);
sbuf->st_mode |= S_IFREG;
sbuf->st_size = nsize;
if (ftpfs.blksize) {
diff --git a/tests/ftpfs-ls_unittest.c b/tests/ftpfs-ls_unittest.c
index 79f792c..e0c3a34 100644
--- a/tests/ftpfs-ls_unittest.c
+++ b/tests/ftpfs-ls_unittest.c
@@ -138,5 +138,10 @@ int main(int argc, char **argv) {
assert(err == 0);
check(sbuf, 0, 0, S_IFDIR|S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IXOTH, 144, 0, 0, 0, 10240, 4096, 24, "00:00:00 31/12/2005");
+ list = "-rw------- 1 6700 2000 6561177600 Oct 15 2005 home.backup.tar\r\n";
+ err = parse_dir(list, "/", "home.backup.tar", &sbuf, NULL, 0, NULL, NULL);
+ assert(err == 0);
+ check(sbuf, 0, 0, S_IFREG|S_IRUSR|S_IWUSR, 1, 0, 0, 0, 6561177600LL, 4096, 4426192, "00:00:00 15/10/2005");
+
return 0;
}