File 0409-erts-Fix-code-checker-warning-in-dyn_erl.c.patch of Package erlang

From e25ccb6471f804729eb1ba0e9223d14dd080cfd9 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Mon, 8 Feb 2021 13:22:59 +0100
Subject: [PATCH 09/34] erts: Fix code checker warning in dyn_erl.c

latest_vsn[-1] was read in first call
and read past end if equals strings.
---
 erts/etc/unix/dyn_erl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/erts/etc/unix/dyn_erl.c b/erts/etc/unix/dyn_erl.c
index c4a2f7217c..f56ecd9d6f 100644
--- a/erts/etc/unix/dyn_erl.c
+++ b/erts/etc/unix/dyn_erl.c
@@ -220,6 +220,11 @@ copy_latest_vsn(char *latest_vsn, char *next_vsn)
     char *np;
     BOOL greater;
 
+    if (latest_vsn[0] == '\0') {
+        strcpy(latest_vsn, next_vsn);
+        return;
+    }
+
     /* Find vsn */
     for (lp = latest_vsn+strlen(latest_vsn)-1 ;lp > latest_vsn && *lp != DIRSEPCHAR; --lp)
 	;
@@ -230,7 +235,7 @@ copy_latest_vsn(char *latest_vsn, char *next_vsn)
 
     /* np =+ length("erts-"); */
     while (TRUE) {
-        if (*lp != *np) {
+        if (*lp != *np || *lp == '\0') {
 	    if (*np > *lp) {
 		greater = TRUE;
 	    } else {
-- 
2.26.2

openSUSE Build Service is sponsored by