@@ -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? */
@@ -1281,7 +1285,9 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url,
1281
1285
ret = VCWD_UNLINK (url );
1282
1286
if (ret == -1 ) {
1283
1287
if (options & REPORT_ERRORS ) {
1284
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1288
+ char errstr [256 ];
1289
+ php_error_docref1 (NULL , url , E_WARNING , "%s" ,
1290
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1285
1291
}
1286
1292
return 0 ;
1287
1293
}
@@ -1327,6 +1333,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1327
1333
1328
1334
if (ret == -1 ) {
1329
1335
#ifndef PHP_WIN32
1336
+ char errstr [256 ];
1330
1337
# ifdef EXDEV
1331
1338
if (errno == EXDEV ) {
1332
1339
zend_stat_t sb ;
@@ -1347,15 +1354,17 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1347
1354
* access to the file in the meantime.
1348
1355
*/
1349
1356
if (VCWD_CHOWN (url_to , sb .st_uid , sb .st_gid )) {
1350
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1357
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1358
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1351
1359
if (errno != EPERM ) {
1352
1360
success = 0 ;
1353
1361
}
1354
1362
}
1355
1363
1356
1364
if (success ) {
1357
1365
if (VCWD_CHMOD (url_to , sb .st_mode )) {
1358
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1366
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1367
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1359
1368
if (errno != EPERM ) {
1360
1369
success = 0 ;
1361
1370
}
@@ -1366,10 +1375,12 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1366
1375
VCWD_UNLINK (url_from );
1367
1376
}
1368
1377
} else {
1369
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1378
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1379
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1370
1380
}
1371
1381
} else {
1372
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1382
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1383
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1373
1384
}
1374
1385
# if !defined(ZTS ) && !defined(TSRM_WIN32 )
1375
1386
umask (oldmask );
@@ -1382,7 +1393,8 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1382
1393
#ifdef PHP_WIN32
1383
1394
php_win32_docref2_from_error (GetLastError (), url_from , url_to );
1384
1395
#else
1385
- php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" , strerror (errno ));
1396
+ php_error_docref2 (NULL , url_from , url_to , E_WARNING , "%s" ,
1397
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1386
1398
#endif
1387
1399
return 0 ;
1388
1400
}
@@ -1462,11 +1474,12 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1462
1474
if (!p ) {
1463
1475
p = buf ;
1464
1476
}
1477
+ char errstr [256 ];
1465
1478
while (true) {
1466
1479
int ret = VCWD_MKDIR (buf , (mode_t ) mode );
1467
1480
if (ret < 0 && errno != EEXIST ) {
1468
1481
if (options & REPORT_ERRORS ) {
1469
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1482
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1470
1483
}
1471
1484
return 0 ;
1472
1485
}
@@ -1486,7 +1499,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1486
1499
/* issue a warning to client when the last directory was created failed */
1487
1500
if (ret < 0 ) {
1488
1501
if (options & REPORT_ERRORS ) {
1489
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1502
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1490
1503
}
1491
1504
return 0 ;
1492
1505
}
@@ -1505,15 +1518,16 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i
1505
1518
return 0 ;
1506
1519
}
1507
1520
1521
+ char errstr [256 ];
1508
1522
#ifdef PHP_WIN32
1509
1523
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1510
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1524
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (ENOENT , errstr , sizeof ( errstr ) ));
1511
1525
return 0 ;
1512
1526
}
1513
1527
#endif
1514
1528
1515
1529
if (VCWD_RMDIR (url ) < 0 ) {
1516
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1530
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (errno , errstr , sizeof ( errstr ) ));
1517
1531
return 0 ;
1518
1532
}
1519
1533
@@ -1532,10 +1546,11 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1532
1546
#endif
1533
1547
mode_t mode ;
1534
1548
int ret = 0 ;
1549
+ char errstr [256 ];
1535
1550
1536
1551
#ifdef PHP_WIN32
1537
1552
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1538
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1553
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror_s (ENOENT , errstr , sizeof ( errstr ) ));
1539
1554
return 0 ;
1540
1555
}
1541
1556
#endif
@@ -1554,7 +1569,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1554
1569
if (VCWD_ACCESS (url , F_OK ) != 0 ) {
1555
1570
FILE * file = VCWD_FOPEN (url , "w" );
1556
1571
if (file == NULL ) {
1557
- php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url , strerror (errno ));
1572
+ php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url ,
1573
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1558
1574
return 0 ;
1559
1575
}
1560
1576
fclose (file );
@@ -1597,7 +1613,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1597
1613
return 0 ;
1598
1614
}
1599
1615
if (ret == -1 ) {
1600
- php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" , strerror (errno ));
1616
+ php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" ,
1617
+ php_socket_strerror_s (errno , errstr , sizeof (errstr )));
1601
1618
return 0 ;
1602
1619
}
1603
1620
php_clear_stat_cache (0 , NULL , 0 );
0 commit comments