Skip to contentSkip to conversation

fddi: skfp: fix null pointer deferenece in smt.c

PATCH In review Siddarth Gundu 2 participants 2 messages May 7, 2025 – May 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fddi: skfp: fix null pointer deferenece in smt.c

In smt_string_swap(), when a closing bracket ']' is encountered before any opening bracket '[' open_paren would be NULL, and assigning it to format would lead to a null pointer being dereferenced in the format++ statement.

Add a check to verify open_paren is non-NULL before assigning it to format

This issue was reported by Coverity Scan.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

---
v2:
- fix commit message
- Add mention of Coverity Scan
- Update Fixes tag to reference initial commit
v1: https://lore.kernel.org/all/[email protected]/

 drivers/net/fddi/skfp/smt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/fddi/skfp/smt.c +2 -1
index dd15af4e98c2..174f279b89ac 100644
@@ -1857,7 +1857,8 @@ static void smt_string_swap(char *data, const char *format, int len)
 			open_paren = format ;
 			break ;
 		case ']' :
-			format = open_paren ;
+			if (open_paren)
+				format = open_paren ;
 			break ;
 		case '1' :
 		case '2' :
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 7 lines · On Thu, 8 May 2025 02:07:06 +0530 Siddarth Gundu wrote:

In smt_string_swap(), when a closing bracket ']' is encountered before any opening bracket '[' open_paren would be NULL, and assigning it to format would lead to a null pointer being dereferenced in the format++ statement.

Add a check to verify open_paren is non-NULL before assigning it to format

You'd have to explain where an invalid format could come from. As far as I can tell they are all hardcoded (grep for SWAP_SMT)

Signature · 1 line
pw-bot: cr