cvs: /php4/ext/session mod_files.c

From: Date: Thu, 21 Oct 1999 12:29:07 +0000
Subject: cvs: /php4/ext/session mod_files.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-5625@lists.php.net to get a copy of this message
sas Thu Oct 21 08:29:07 1999 EDT Modified files: /php4/ext/session mod_files.c Log: (_ps_files_open): evaluate key (session id) before path creation Index: php4/ext/session/mod_files.c diff -u php4/ext/session/mod_files.c:1.16 php4/ext/session/mod_files.c:1.17 --- php4/ext/session/mod_files.c:1.16 Sat Sep 11 13:20:31 1999 +++ php4/ext/session/mod_files.c Thu Oct 21 08:28:36 1999 @@ -61,6 +61,32 @@ #define DIR_DELIMITER '/' #endif +static int _ps_files_valid_key(const char *key) +{ + size_t len; + const char *p; + char c; + int ret = 1; + + for(p = key; (c = *p); p++) { + /* valid characters are a..z,A..Z,0..9 */ + if(!(c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9')) { + ret = 0; + break; + } + } + + len = p - key; + + if(len == 0) { + ret = 0; + } + + return ret; +} + static char *_ps_files_path_create(char *buf, size_t buflen, ps_files *data, const char *key) { int keylen; @@ -98,7 +124,8 @@ data->fd = -1; } - if(!_ps_files_path_create(buf, sizeof(buf), data, key)) + if(!_ps_files_valid_key(key) || + !_ps_files_path_create(buf, sizeof(buf), data, key)) return; data->lastkey = estrdup(key);

« previous php.version4 (#5625) next »