Le test buf.st_size > Max_long n'est reellement significatif que pour les fichiers normaux (PR#1410)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5144 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2002-09-27 08:32:28 +00:00
parent 580e761639
commit 9226b2a3b6
1 changed files with 6 additions and 3 deletions

View File

@ -78,7 +78,8 @@ CAMLprim value unix_stat(value path)
struct stat buf;
ret = stat(String_val(path), &buf);
if (ret == -1) uerror("stat", path);
if (buf.st_size > Max_long) unix_error(EOVERFLOW, "stat", path);
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "stat", path);
return stat_aux(0, &buf);
}
@ -92,7 +93,8 @@ CAMLprim value unix_lstat(value path)
ret = stat(String_val(path), &buf);
#endif
if (ret == -1) uerror("lstat", path);
if (buf.st_size > Max_long) unix_error(EOVERFLOW, "lstat", path);
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "lstat", path);
return stat_aux(0, &buf);
}
@ -102,7 +104,8 @@ CAMLprim value unix_fstat(value fd)
struct stat buf;
ret = fstat(Int_val(fd), &buf);
if (ret == -1) uerror("fstat", Nothing);
if (buf.st_size > Max_long) unix_error(EOVERFLOW, "fstat", Nothing);
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "fstat", Nothing);
return stat_aux(0, &buf);
}