[clang] [Clang][Sema] Add fortify warnings for fread, fwrite, and fgets (PR #204337)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 17 04:50:11 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Linux-->
# :penguin: Linux x64 Test Results

* 88329 tests passed
* 1663 tests skipped
* 2 tests failed

## Failed Tests
(click on a test name to see its output)

### Clang
<details>
<summary>Clang.Analysis/std-c-library-functions-arg-constraints.c</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/23/include -nostdsysteminc -analyze -setup-static-analyzer /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/std-c-library-functions-arg-constraints.c    -analyzer-checker=core    -analyzer-checker=unix.StdCLibraryFunctions    -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true    -analyzer-checker=debug.StdCLibraryFunctionsTester    -analyzer-checker=debug.ExprInspection    -triple x86_64-unknown-linux-gnu    -verify=report
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/23/include -nostdsysteminc -analyze -setup-static-analyzer /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/std-c-library-functions-arg-constraints.c -analyzer-checker=core -analyzer-checker=unix.StdCLibraryFunctions -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true -analyzer-checker=debug.StdCLibraryFunctionsTester -analyzer-checker=debug.ExprInspection -triple x86_64-unknown-linux-gnu -verify=report
# .---command stderr------------
# | error: 'report-warning' diagnostics seen but not expected: 
# |   File /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/std-c-library-functions-arg-constraints.c Line 247: 'fread' will always overflow; destination buffer has size 4096, but size argument is 16384
# | 1 error generated.
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>Clang.Analysis/stream-noopen.c</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/23/include -nostdsysteminc -analyze -setup-static-analyzer -verify /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/stream-noopen.c    -analyzer-checker=core    -analyzer-checker=unix.Errno    -analyzer-checker=unix.Stream    -analyzer-checker=unix.StdCLibraryFunctions    -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true    -analyzer-checker=debug.ExprInspection
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/23/include -nostdsysteminc -analyze -setup-static-analyzer -verify /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/stream-noopen.c -analyzer-checker=core -analyzer-checker=unix.Errno -analyzer-checker=unix.Stream -analyzer-checker=unix.StdCLibraryFunctions -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true -analyzer-checker=debug.ExprInspection
# .---command stderr------------
# | error: 'expected-warning' diagnostics seen but not expected: 
# |   File /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/stream-noopen.c Line 102: 'fgets' size argument is too large; destination buffer has size 10, but size argument is 11
# |   File /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Analysis/stream-noopen.c Line 107: 'fgets' size argument is too large; destination buffer has size 10, but size argument is 11
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/204337


More information about the cfe-commits mailing list