[PR #6859] [MERGED] bugfix: fix potential infinite loop in checkcfg (-fanalyzer) #6202

Closed
opened 2026-05-05 10:52:38 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netblue30/firejail/pull/6859
Author: @kmk3
Created: 8/13/2025
Status: Merged
Merged: 8/15/2025
Merged by: @kmk3

Base: masterHead: checkcfg-fix-infinite-loop


📝 Commits (1)

  • 3f85fa2 bugfix: fix potential infinite loop in checkcfg (-fanalyzer)

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 src/firejail/checkcfg.c (+1 -1)

📄 Description

It looks like it could happen if a line in /etc/firejail/firejail.config
starts with netfilter-default and there is a space or tab right after
that.

$ pacman -Q gcc14 glibc
gcc14 14.3.1+r25+g42e99e057bd7-1
glibc 2.42+r3+gbc13db739377-1
$ ./configure --enable-analyzer CC=gcc-14 >/dev/null &&
  make clean >/dev/null && make >/dev/null
[...]
../../src/firejail/checkcfg.c: In function ‘checkcfg’:
../../src/firejail/checkcfg.c:137:40: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop]
  137 |                                 while (*fname == ' ' || *fname == '\t')
      |                                        ^~~~~~
  ‘checkcfg’: events 1-5
    |
    |  137 |                                 while (*fname == ' ' || *fname == '\t')
    |      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                                        |             |
    |      |                                        |             (2) if it ever follows ‘true’ branch, it will always do so...
    |      |                                        (1) infinite loop here
    |      |                                        (5) ...to here
    |  138 |                                         ptr++;
    |      |                                         ~~~~~
    |      |                                            |
    |      |                                            (3) ...to here
    |      |                                            (4) looping back...
    |
[...]

Added on commit 340a6b2ee ("added netfilter-default config option in
/etc/firejail/firejail.config", 2016-07-28).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netblue30/firejail/pull/6859 **Author:** [@kmk3](https://github.com/kmk3) **Created:** 8/13/2025 **Status:** ✅ Merged **Merged:** 8/15/2025 **Merged by:** [@kmk3](https://github.com/kmk3) **Base:** `master` ← **Head:** `checkcfg-fix-infinite-loop` --- ### 📝 Commits (1) - [`3f85fa2`](https://github.com/netblue30/firejail/commit/3f85fa29cad3a844d73ac03011c7f3eb7ead1ceb) bugfix: fix potential infinite loop in checkcfg (-fanalyzer) ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/firejail/checkcfg.c` (+1 -1) </details> ### 📄 Description It looks like it could happen if a line in /etc/firejail/firejail.config starts with `netfilter-default ` and there is a space or tab right after that. $ pacman -Q gcc14 glibc gcc14 14.3.1+r25+g42e99e057bd7-1 glibc 2.42+r3+gbc13db739377-1 $ ./configure --enable-analyzer CC=gcc-14 >/dev/null && make clean >/dev/null && make >/dev/null [...] ../../src/firejail/checkcfg.c: In function ‘checkcfg’: ../../src/firejail/checkcfg.c:137:40: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop] 137 | while (*fname == ' ' || *fname == '\t') | ^~~~~~ ‘checkcfg’: events 1-5 | | 137 | while (*fname == ' ' || *fname == '\t') | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | (2) if it ever follows ‘true’ branch, it will always do so... | | (1) infinite loop here | | (5) ...to here | 138 | ptr++; | | ~~~~~ | | | | | (3) ...to here | | (4) looping back... | [...] Added on commit 340a6b2ee ("added netfilter-default config option in /etc/firejail/firejail.config", 2016-07-28). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 10:52:38 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#6202
No description provided.