fddi: skfp: fix null pointer deferenece in smt.c
Subsystems (2)
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.
---
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
@@ -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
Jakub Kicinski
maintainerQuoted 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_parenwould 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_parenis 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