aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMarcus Arendt <[email protected]>2014-06-04 11:50:01 +0200
committerMarcus Arendt <[email protected]>2014-06-04 11:50:01 +0200
commit596f214fc0275df8b19a8b36bb7b71e6affc6bd5 (patch)
tree0c916480087a992e45341da138443013c73cf321 /erts
parentd0893c4c5532116d5b5cb360b5ed3861fb7b25a1 (diff)
parent78540afe8d4a15fe3d6c42208b82bde546e4c0c8 (diff)
downloadotp-596f214fc0275df8b19a8b36bb7b71e6affc6bd5.tar.gz
otp-596f214fc0275df8b19a8b36bb7b71e6affc6bd5.tar.bz2
otp-596f214fc0275df8b19a8b36bb7b71e6affc6bd5.zip
Merge branch 'mikpe/openfile-dont-use-undefined-statbuf' into maint
* mikpe/openfile-dont-use-undefined-statbuf: Fix efile_openfile() to handle stat() failure
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/drivers/unix/unix_efile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/erts/emulator/drivers/unix/unix_efile.c b/erts/emulator/drivers/unix/unix_efile.c
index 42f41c5f3d..878beb055b 100644
--- a/erts/emulator/drivers/unix/unix_efile.c
+++ b/erts/emulator/drivers/unix/unix_efile.c
@@ -360,7 +360,12 @@ efile_openfile(Efile_error* errInfo, /* Where to return error codes. */
int fd;
int mode; /* Open mode. */
- if (stat(name, &statbuf) >= 0 && !ISREG(statbuf)) {
+ if (stat(name, &statbuf) < 0) {
+ /* statbuf is undefined: if the caller depends on it,
+ i.e. invoke_read_file(), fail the call immediately */
+ if (pSize && flags == EFILE_MODE_READ)
+ return check_error(-1, errInfo);
+ } else if (!ISREG(statbuf)) {
/*
* For UNIX only, here is some ugly code to allow
* /dev/null to be opened as a file.