~legolas/ubuntu/natty/php5/5.3.5

« back to all changes in this revision

Viewing changes to main/streams/plain_wrapper.c

  • Committer: Stas Verberkt
  • Date: 2011-02-01 09:27:15 UTC
  • Revision ID: legolas@legolasweb.nl-20110201092715-yq052iu2yl4i2eyg
Inserted PHP 5.3.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
   +----------------------------------------------------------------------+
17
17
 */
18
18
 
19
 
/* $Id: plain_wrapper.c 295308 2010-02-21 17:44:25Z pajoye $ */
 
19
/* $Id: plain_wrapper.c 305108 2010-11-05 18:53:48Z cataphract $ */
20
20
 
21
21
#include "php.h"
22
22
#include "php_globals.h"
490
490
                                if (data->file == NULL) {
491
491
                                        /* we were opened as a plain file descriptor, so we
492
492
                                         * need fdopen now */
493
 
                                        data->file = fdopen(data->fd, stream->mode);
 
493
                                        char fixed_mode[5];
 
494
                                        php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode);
 
495
                                        data->file = fdopen(data->fd, fixed_mode);
494
496
                                        if (data->file == NULL) {
495
497
                                                return FAILURE;
496
498
                                        }
1017
1019
                return -1;
1018
1020
        }
1019
1021
 
1020
 
#ifdef HAVE_SYMLINK
 
1022
#ifdef PHP_WIN32
 
1023
        if (EG(windows_version_info).dwMajorVersion >= 5) {
 
1024
                if (flags & PHP_STREAM_URL_STAT_LINK) {
 
1025
                        return VCWD_LSTAT(url, &ssb->sb);
 
1026
                }
 
1027
        }
 
1028
#else
 
1029
# ifdef HAVE_SYMLINK
1021
1030
        if (flags & PHP_STREAM_URL_STAT_LINK) {
1022
1031
                return VCWD_LSTAT(url, &ssb->sb);
1023
1032
        } else
 
1033
# endif
1024
1034
#endif
1025
1035
                return VCWD_STAT(url, &ssb->sb);
1026
1036
}
1139
1149
#else
1140
1150
                php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
1141
1151
#endif
1142
 
        return 0;
 
1152
                return 0;
1143
1153
        }
1144
1154
 
1145
1155
        /* Clear stat cache (and realpath cache) */
1221
1231
                                if (*p == '\0') {
1222
1232
                                        *p = DEFAULT_SLASH;
1223
1233
                                        if ((*(p+1) != '\0') &&
1224
 
                                            (ret = VCWD_MKDIR(buf, (mode_t)mode)) < 0) {
 
1234
                                                (ret = VCWD_MKDIR(buf, (mode_t)mode)) < 0) {
1225
1235
                                                if (options & REPORT_ERRORS) {
1226
1236
                                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
1227
1237
                                                }
1298
1308
        char *pathbuf, *ptr, *end;
1299
1309
        char *exec_fname;
1300
1310
        char trypath[MAXPATHLEN];
1301
 
        struct stat sb;
1302
1311
        php_stream *stream;
1303
1312
        int path_length;
1304
1313
        int filename_length;
1440
1449
                }
1441
1450
                
1442
1451
                if (PG(safe_mode)) {
 
1452
                        struct stat sb;
 
1453
 
1443
1454
                        if (VCWD_STAT(trypath, &sb) == 0) {
1444
1455
                                /* file exists ... check permission */
1445
1456
                                if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) ||