diff options
| author | Yasuo Ohgaki <yohgaki@php.net> | 2002-02-03 03:17:35 +0000 |
|---|---|---|
| committer | Yasuo Ohgaki <yohgaki@php.net> | 2002-02-03 03:17:35 +0000 |
| commit | 4c6e58ac597be7565bd8715520e28a35f9dd2931 (patch) | |
| tree | db4d7f2f3dd8f6385facf0dd54ab3babe6608749 /ext/session/mod_files.c | |
| parent | 665d38629b818d2d24f9c532c183b85b3492b464 (diff) | |
| download | php-git-4c6e58ac597be7565bd8715520e28a35f9dd2931.tar.gz | |
Fixed crash when save_path is invalid.
Fixed crash when user save handler is incorrectly used.
Fixed crash when session read failed.
Diffstat (limited to 'ext/session/mod_files.c')
| -rw-r--r-- | ext/session/mod_files.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 96f0c3a93e..ce6365365e 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -123,7 +123,7 @@ static void ps_files_close(ps_files *data) } } -static void ps_files_open(ps_files *data, const char *key) +static int ps_files_open(ps_files *data, const char *key) { char buf[MAXPATHLEN]; TSRMLS_FETCH(); @@ -138,7 +138,7 @@ static void ps_files_open(ps_files *data, const char *key) if (!ps_files_valid_key(key) || !ps_files_path_create(buf, sizeof(buf), data, key)) - return; + return FAILURE; data->lastkey = estrdup(key); @@ -153,10 +153,13 @@ static void ps_files_open(ps_files *data, const char *key) if (data->fd != -1) flock(data->fd, LOCK_EX); - if (data->fd == -1) + if (data->fd == -1) { php_error(E_WARNING, "open(%s, O_RDWR) failed: %s (%d)", buf, strerror(errno), errno); + return FAILURE; + } } + return SUCCESS; } static int ps_files_cleanup_dir(const char *dirname, int maxlifetime) @@ -254,7 +257,9 @@ PS_READ_FUNC(files) struct stat sbuf; PS_FILES_DATA; - ps_files_open(data, key); + if (ps_files_open(data, key) == FAILURE) + return FAILURE; + if (data->fd < 0) return FAILURE; @@ -283,7 +288,9 @@ PS_WRITE_FUNC(files) long n; PS_FILES_DATA; - ps_files_open(data, key); + if (ps_files_open(data, key) == FAILURE) + return FAILURE; + if (data->fd < 0) return FAILURE; |
