@@ -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 (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 (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 (errno , errstr , sizeof (errstr )));
1282
1288
}
1283
1289
return 0 ;
1284
1290
}
@@ -1321,6 +1327,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
1321
1327
}
1322
1328
1323
1329
ret = VCWD_RENAME (url_from , url_to );
1330
+ char errstr [256 ];
1324
1331
1325
1332
if (ret == -1 ) {
1326
1333
#ifndef PHP_WIN32
@@ -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 (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 (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 (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 (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 (errno , errstr , sizeof (errstr )));
1383
1395
#endif
1384
1396
return 0 ;
1385
1397
}
@@ -1449,11 +1461,12 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1449
1461
if (!p ) {
1450
1462
p = buf ;
1451
1463
}
1464
+ char errstr [256 ];
1452
1465
while (true) {
1453
1466
int ret = VCWD_MKDIR (buf , (mode_t ) mode );
1454
1467
if (ret < 0 && errno != EEXIST ) {
1455
1468
if (options & REPORT_ERRORS ) {
1456
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1469
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror (errno , errstr , sizeof ( errstr ) ));
1457
1470
}
1458
1471
return 0 ;
1459
1472
}
@@ -1473,7 +1486,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
1473
1486
/* issue a warning to client when the last directory was created failed */
1474
1487
if (ret < 0 ) {
1475
1488
if (options & REPORT_ERRORS ) {
1476
- php_error_docref (NULL , E_WARNING , "%s" , strerror (errno ));
1489
+ php_error_docref (NULL , E_WARNING , "%s" , php_socket_strerror (errno , errstr , sizeof ( errstr ) ));
1477
1490
}
1478
1491
return 0 ;
1479
1492
}
@@ -1492,15 +1505,16 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i
1492
1505
return 0 ;
1493
1506
}
1494
1507
1508
+ char errstr [256 ];
1495
1509
#ifdef PHP_WIN32
1496
1510
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1497
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1511
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror (ENOENT , errstr , sizeof ( errstr ) ));
1498
1512
return 0 ;
1499
1513
}
1500
1514
#endif
1501
1515
1502
1516
if (VCWD_RMDIR (url ) < 0 ) {
1503
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (errno ));
1517
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror (errno , errstr , sizeof ( errstr ) ));
1504
1518
return 0 ;
1505
1519
}
1506
1520
@@ -1519,10 +1533,11 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1519
1533
#endif
1520
1534
mode_t mode ;
1521
1535
int ret = 0 ;
1536
+ char errstr [256 ];
1522
1537
1523
1538
#ifdef PHP_WIN32
1524
1539
if (!php_win32_check_trailing_space (url , strlen (url ))) {
1525
- php_error_docref1 (NULL , url , E_WARNING , "%s" , strerror (ENOENT ));
1540
+ php_error_docref1 (NULL , url , E_WARNING , "%s" , php_socket_strerror (ENOENT , errstr , sizeof ( errstr ) ));
1526
1541
return 0 ;
1527
1542
}
1528
1543
#endif
@@ -1541,7 +1556,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1541
1556
if (VCWD_ACCESS (url , F_OK ) != 0 ) {
1542
1557
FILE * file = VCWD_FOPEN (url , "w" );
1543
1558
if (file == NULL ) {
1544
- php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url , strerror (errno ));
1559
+ php_error_docref1 (NULL , url , E_WARNING , "Unable to create file %s because %s" , url ,
1560
+ php_socket_strerror (errno , errstr , sizeof (errstr )));
1545
1561
return 0 ;
1546
1562
}
1547
1563
fclose (file );
@@ -1584,7 +1600,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
1584
1600
return 0 ;
1585
1601
}
1586
1602
if (ret == -1 ) {
1587
- php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" , strerror (errno ));
1603
+ php_error_docref1 (NULL , url , E_WARNING , "Operation failed: %s" , php_socket_strerror (errno , errstr , sizeof ( errstr ) ));
1588
1604
return 0 ;
1589
1605
}
1590
1606
php_clear_stat_cache (0 , NULL , 0 );
0 commit comments