File plannif_scanf-avoid-underflow.patch of Package sispmctl

From: Heinrich Schuchardt <xypron.glpk@gmx.de>
Date: Fri Nov 15 17:55:34 2024 +0100
Subject: plannif_scanf: avoid underflow
Patch-mainline: Not yet
Git-repo: https://git.code.sf.net/p/sispmctl/git
Git-commit: fb9ba6c7afba5220a4e838e487a643406c373f86
References: 

Avoid unexpected socket number when reading a schedule.

Addresses-Coverity-ID: 512015 Unintended sign extension
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Egbert Eich <eich@suse.de>
---
 src/sispm_ctl.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/src/sispm_ctl.c b/src/sispm_ctl.c
index c594adc..8da24b8 100644
--- a/src/sispm_ctl.c
+++ b/src/sispm_ctl.c
@@ -332,6 +332,8 @@ void plannif_scanf(struct plannif *plan, const unsigned char *buffer)
   int actionNo = 1;
 
   READNEXTBYTE;
+  if (!nextWord)
+    nextWord = 1;
   plan->socket = (nextWord - 1) / 3;
   READNEXTDOUBLEWORD;
   plan->timeStamp = nextWord;
openSUSE Build Service is sponsored by