@@ -367,7 +367,9 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
367
367
return bytes_written ;
368
368
}
369
369
if (!(stream -> flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS )) {
370
- php_error_docref (NULL , E_NOTICE , "Write of %zu bytes failed with errno=%d %s" , count , errno , strerror (errno ));
370
+ char errstr [256 ];
371
+ php_error_docref (NULL , E_NOTICE , "Write of %zu bytes failed with errno=%d %s" ,
372
+ count , errno , php_socket_strerror_s (errno , errstr , sizeof (errstr )));
371
373
}
372
374
}
373
375
} else {
@@ -443,7 +445,9 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
443
445
/* TODO: Should this be treated as a proper error or not? */
444
446
} else {
445
447
if (!(stream -> flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS )) {
446
- php_error_docref (NULL , E_NOTICE , "Read of %zu bytes failed with errno=%d %s" , count , errno , strerror (errno ));
448
+ char errstr [256 ];
449
+ php_error_docref (NULL , E_NOTICE , "Read of %zu bytes failed with errno=%d %s" ,
450
+ count , errno , php_socket_strerror_s (errno , errstr , sizeof (errstr )));
447
451
}
448
452
449
453
/* TODO: Remove this special-case? */
@@ -1257,7 +1261,9 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url,
1257
1261
ret = VCWD_UNLINK (url );
1258
1262
if (ret == -1 ) {
1259
1263
if (options & REPORT_ERRORS ) {
1260
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1264
+ char errstr [256 ];
1265
+ php_error_docref1 (NULL , url , E_WARNING , "%s" ,
1266
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1261
1267
}
1262
1268
return 0 ;
1263
1269
}
@@ -1300,6 +1306,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1300
1306
}
1301
1307
1302
1308
ret = VCWD_RENAME (url_from , url_to );
1309
+ char errstr [256 ];
1303
1310
1304
1311
if (ret == -1 ) {
1305
1312
#ifndef PHP_WIN32
@@ -1323,15 +1330,17 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1323
1330
* access to the file in the meantime.
1324
1331
*/
1325
1332
if (VCWD_CHOWN (url_to , sb .st_uid , sb .st_gid )) {
1326
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1333
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1334
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1327
1335
if (errno != EPERM ) {
1328
1336
success = 0 ;
1329
1337
}
1330
1338
}
1331
1339
1332
1340
if (success ) {
1333
1341
if (VCWD_CHMOD (url_to , sb .st_mode )) {
1334
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1342
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1343
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1335
1344
if (errno != EPERM ) {
1336
1345
success = 0 ;
1337
1346
}
@@ -1342,10 +1351,12 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1342
1351
VCWD_UNLINK (url_from );
1343
1352
}
1344
1353
} else {
1345
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1354
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1355
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1346
1356
}
1347
1357
} else {
1348
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1358
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1359
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1349
1360
}
1350
1361
# if !defined(ZTS ) && !defined(TSRM_WIN32 )
1351
1362
umask (oldmask );
@@ -1358,7 +1369,8 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1358
1369
#ifdef PHP_WIN32
1359
1370
php_win32_docref2_from_error (GetLastError (), url_from , url_to );
1360
1371
#else
1361
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1372
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1373
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1362
1374
#endif
1363
1375
return 0 ;
1364
1376
}
@@ -1438,11 +1450,12 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1438
1450
if (!p ) {
1439
1451
p = buf ;
1440
1452
}
1453
+ char errstr [256 ];
1441
1454
while (true) {
1442
1455
int ret = VCWD_MKDIR (buf , (mode_t ) mode );
1443
1456
if (ret < 0 && errno != EEXIST ) {
1444
1457
if (options & REPORT_ERRORS ) {
1445
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1458
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1446
1459
}
1447
1460
return 0 ;
1448
1461
}
@@ -1462,7 +1475,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1462
1475
/* issue a warning to client when the last directory was created failed */
1463
1476
if (ret < 0 ) {
1464
1477
if (options & REPORT_ERRORS ) {
1465
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1478
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1466
1479
}
1467
1480
return 0 ;
1468
1481
}
@@ -1481,15 +1494,16 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i
1481
1494
return 0 ;
1482
1495
}
1483
1496
1497
+ char errstr [256 ];
1484
1498
#ifdef PHP_WIN32
1485
1499
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1486
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1500
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (ENOENT , errstr , sizeof ( errstr ) ));
1487
1501
return 0 ;
1488
1502
}
1489
1503
#endif
1490
1504
1491
1505
if (VCWD_RMDIR (url ) < 0 ) {
1492
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1506
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1493
1507
return 0 ;
1494
1508
}
1495
1509
@@ -1508,10 +1522,11 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1508
1522
#endif
1509
1523
mode_t mode ;
1510
1524
int ret = 0 ;
1525
+ char errstr [256 ];
1511
1526
1512
1527
#ifdef PHP_WIN32
1513
1528
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1514
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1529
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (ENOENT , errstr , sizeof ( errstr ) ));
1515
1530
return 0 ;
1516
1531
}
1517
1532
#endif
@@ -1530,7 +1545,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1530
1545
if (VCWD_ACCESS (url , F_OK ) != 0 ) {
1531
1546
FILE * file = VCWD_FOPEN (url , "w" );
1532
1547
if (file == NULL ) {
1533
- php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url , strerror (errno ));
1548
+ php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url ,
1549
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1534
1550
return 0 ;
1535
1551
}
1536
1552
fclose (file );
@@ -1573,7 +1589,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1573
1589
return 0 ;
1574
1590
}
1575
1591
if (ret == -1 ) {
1576
- php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" , strerror (errno ));
1592
+ php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" ,
1593
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1577
1594
return 0 ;
1578
1595
}
1579
1596
php_clear_stat_cache (0 , NULL , 0 );
0 commit comments