Commit 4f2c94a
Fix warnings and truncations around
* filesize_to_str(): accept uint64_t, not size_t
On 32-bit platforms, we would otherwise perform a 40-bit shift of a
32-bit size_t, which is undefined behaviour. Moreover, files can be
larger than the address space of the process.
* fread: better error for files that are too large
On non-Windows, print the errno when file exists but we couldn't open
it. That will happen for files larger than the address space when off_t
is 32-bit (default on Linux+glibc).
In case an operating system does let us open a large file, check the
size before casting it to size_t. (This happens at least on Windows.)
* filesize_to_str(): print binary SI prefixes
* Update src/fread.c
Co-authored-by: Michael Chirico <[email protected]>
* Print both file size and SIZE_MAX upon failure
Co-authored-by: Michael Chirico <[email protected]>
* NEWS entries
* Fix double blunder
- Make sure to use the right platform-specific variable in both cases
- Can't use filesize_to_str() more than once due to its static buffer
* tweak NEWS
---------
Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>filesize_to_str() (#6987)1 parent db834d4 commit 4f2c94a
2 files changed
+24
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
430 | | - | |
| 429 | + | |
| 430 | + | |
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
1415 | 1415 | | |
1416 | 1416 | | |
1417 | 1417 | | |
1418 | | - | |
| 1418 | + | |
1419 | 1419 | | |
1420 | 1420 | | |
1421 | 1421 | | |
1422 | 1422 | | |
1423 | 1423 | | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
1424 | 1428 | | |
1425 | 1429 | | |
1426 | 1430 | | |
| |||
1453 | 1457 | | |
1454 | 1458 | | |
1455 | 1459 | | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1456 | 1464 | | |
1457 | | - | |
| 1465 | + | |
1458 | 1466 | | |
1459 | 1467 | | |
1460 | 1468 | | |
| |||
0 commit comments