@@ -368,7 +368,9 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
368
368
return bytes_written ;
369
369
}
370
370
if (!(stream -> flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS )) {
371
- php_error_docref (NULL , E_NOTICE , "Write of %zu bytes failed with errno=%d %s" , count , errno , strerror (errno ));
371
+ char errstr [256 ];
372
+ php_error_docref (NULL , E_NOTICE , "Write of %zu bytes failed with errno=%d %s" ,
373
+ count , errno , php_socket_strerror_s (errno , errstr , sizeof (errstr )));
372
374
}
373
375
}
374
376
} else {
@@ -444,7 +446,9 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
444
446
/* TODO: Should this be treated as a proper error or not? */
445
447
} else {
446
448
if (!(stream -> flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS )) {
447
- php_error_docref (NULL , E_NOTICE , "Read of %zu bytes failed with errno=%d %s" , count , errno , strerror (errno ));
449
+ char errstr [256 ];
450
+ php_error_docref (NULL , E_NOTICE , "Read of %zu bytes failed with errno=%d %s" ,
451
+ count , errno , php_socket_strerror_s (errno , errstr , sizeof (errstr )));
448
452
}
449
453
450
454
/* TODO: Remove this special-case? */
@@ -1278,7 +1282,9 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url,
1278
1282
ret = VCWD_UNLINK (url );
1279
1283
if (ret == -1 ) {
1280
1284
if (options & REPORT_ERRORS ) {
1281
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1285
+ char errstr [256 ];
1286
+ php_error_docref1 (NULL , url , E_WARNING , "%s" ,
1287
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1282
1288
}
1283
1289
return 0 ;
1284
1290
}
@@ -1324,6 +1330,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1324
1330
1325
1331
if (ret == -1 ) {
1326
1332
#ifndef PHP_WIN32
1333
+ char errstr [256 ];
1327
1334
# ifdef EXDEV
1328
1335
if (errno == EXDEV ) {
1329
1336
zend_stat_t sb ;
@@ -1344,15 +1351,17 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1344
1351
* access to the file in the meantime.
1345
1352
*/
1346
1353
if (VCWD_CHOWN (url_to , sb .st_uid , sb .st_gid )) {
1347
- 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 )));
1348
1356
if (errno != EPERM ) {
1349
1357
success = 0 ;
1350
1358
}
1351
1359
}
1352
1360
1353
1361
if (success ) {
1354
1362
if (VCWD_CHMOD (url_to , sb .st_mode )) {
1355
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1363
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1364
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1356
1365
if (errno != EPERM ) {
1357
1366
success = 0 ;
1358
1367
}
@@ -1363,10 +1372,12 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1363
1372
VCWD_UNLINK (url_from );
1364
1373
}
1365
1374
} else {
1366
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1375
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1376
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1367
1377
}
1368
1378
} else {
1369
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1379
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1380
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1370
1381
}
1371
1382
# if !defined(ZTS ) && !defined(TSRM_WIN32 )
1372
1383
umask (oldmask );
@@ -1379,7 +1390,8 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1379
1390
#ifdef PHP_WIN32
1380
1391
php_win32_docref2_from_error (GetLastError (), url_from , url_to );
1381
1392
#else
1382
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1393
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1394
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1383
1395
#endif
1384
1396
return 0 ;
1385
1397
}
@@ -1459,11 +1471,12 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1459
1471
if (!p ) {
1460
1472
p = buf ;
1461
1473
}
1474
+ char errstr [256 ];
1462
1475
while (true) {
1463
1476
int ret = VCWD_MKDIR (buf , (mode_t ) mode );
1464
1477
if (ret < 0 && errno != EEXIST ) {
1465
1478
if (options & REPORT_ERRORS ) {
1466
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1479
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1467
1480
}
1468
1481
return 0 ;
1469
1482
}
@@ -1483,7 +1496,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1483
1496
/* issue a warning to client when the last directory was created failed */
1484
1497
if (ret < 0 ) {
1485
1498
if (options & REPORT_ERRORS ) {
1486
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1499
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1487
1500
}
1488
1501
return 0 ;
1489
1502
}
@@ -1502,15 +1515,16 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i
1502
1515
return 0 ;
1503
1516
}
1504
1517
1518
+ char errstr [256 ];
1505
1519
#ifdef PHP_WIN32
1506
1520
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1507
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1521
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (ENOENT , errstr , sizeof ( errstr ) ));
1508
1522
return 0 ;
1509
1523
}
1510
1524
#endif
1511
1525
1512
1526
if (VCWD_RMDIR (url ) < 0 ) {
1513
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1527
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1514
1528
return 0 ;
1515
1529
}
1516
1530
@@ -1529,10 +1543,11 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1529
1543
#endif
1530
1544
mode_t mode ;
1531
1545
int ret = 0 ;
1546
+ char errstr [256 ];
1532
1547
1533
1548
#ifdef PHP_WIN32
1534
1549
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1535
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1550
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (ENOENT , errstr , sizeof ( errstr ) ));
1536
1551
return 0 ;
1537
1552
}
1538
1553
#endif
@@ -1551,7 +1566,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1551
1566
if (VCWD_ACCESS (url , F_OK ) != 0 ) {
1552
1567
FILE * file = VCWD_FOPEN (url , "w" );
1553
1568
if (file == NULL ) {
1554
- php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url , strerror (errno ));
1569
+ php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url ,
1570
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1555
1571
return 0 ;
1556
1572
}
1557
1573
fclose (file );
@@ -1594,7 +1610,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1594
1610
return 0 ;
1595
1611
}
1596
1612
if (ret == -1 ) {
1597
- php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" , strerror (errno ));
1613
+ php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" ,
1614
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1598
1615
return 0 ;
1599
1616
}
1600
1617
php_clear_stat_cache (0 , NULL , 0 );
0 commit comments