summaryrefslogtreecommitdiff
path: root/backport-Fix-a-theoretical-use-of-uninitialized-struct-member.patch
blob: 69a0dc747e774886378382c1cad9b2ca07a5da7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From 656fe42af1d497c35769c740fcc98950e1455bad Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Wed, 24 Jan 2024 12:44:34 +0200
Subject: [PATCH] Fix a theoretical use of uninitialized struct members

If rpmScriptFromTriggerTag() was called with tm other than the three
handled cases in the switch, the rpmtd_s structs would be uninitialized
and weird things could happen. The value of tm is hardwired in all the
existing callers AFAICS but the extra safety doesn't hurt either.

Discovered by static analysis in RHEL.
---
 lib/rpmscript.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/rpmscript.c b/lib/rpmscript.c
index b18f851a3..3f6313278 100644
--- a/lib/rpmscript.c
+++ b/lib/rpmscript.c
@@ -641,6 +641,8 @@ rpmScript rpmScriptFromTriggerTag(Header h, rpmTagVal triggerTag,
 	    headerGet(h, RPMTAG_TRANSFILETRIGGERSCRIPTFLAGS, &tflags, hgflags);
 	    prefix = "transfile";
 	    break;
+	default:
+	    return NULL;
     }
 
     if (rpmtdSetIndex(&tscripts, ix) >= 0 && rpmtdSetIndex(&tprogs, ix) >= 0) {
-- 
2.33.0