diff options
| author | jvoisin | 2023-07-09 18:12:01 +0200 |
|---|---|---|
| committer | jvoisin | 2023-07-09 18:15:35 +0200 |
| commit | a37c769fbbc956461210317fa856be4042c144f4 (patch) | |
| tree | 80c335085b82e6f6ff52101c070f0e3e74119443 /include/stdio.h | |
| parent | f9f83da31803062d1fb665ad612ccede5e445757 (diff) | |
Improve a bit `size_t*size_t` overflow checks
Diffstat (limited to 'include/stdio.h')
| -rw-r--r-- | include/stdio.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/stdio.h b/include/stdio.h index cc16e46..d5206f5 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -53,7 +53,7 @@ _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, | |||
| 53 | { | 53 | { |
| 54 | size_t __b = __bos(__d, 0); | 54 | size_t __b = __bos(__d, 0); |
| 55 | 55 | ||
| 56 | if (__n != 0 && (__n * __m) / __n != __m) | 56 | if (__bmo(__n, __m)) |
| 57 | __builtin_trap(); | 57 | __builtin_trap(); |
| 58 | if (__n * __m > __b) | 58 | if (__n * __m > __b) |
| 59 | __builtin_trap(); | 59 | __builtin_trap(); |
| @@ -66,7 +66,7 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, | |||
| 66 | { | 66 | { |
| 67 | size_t __b = __bos(__d, 0); | 67 | size_t __b = __bos(__d, 0); |
| 68 | 68 | ||
| 69 | if (__n != 0 && (__n * __m) / __n != __m) | 69 | if (__bmo(__n, __m)) |
| 70 | __builtin_trap(); | 70 | __builtin_trap(); |
| 71 | if (__n * __m > __b) | 71 | if (__n * __m > __b) |
| 72 | __builtin_trap(); | 72 | __builtin_trap(); |
