From 5f8baa286c57ebe839069d48c755a90402ef7b77 Mon Sep 17 00:00:00 2001
From: Jiajie Chen <c@jia.je>
Date: Mon, 16 Jan 2023 23:51:03 +0800
Subject: [PATCH] [linux] Fix potential oob write

---
 dialects/linux/dsock.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/dialects/linux/dsock.c b/dialects/linux/dsock.c
index 1fce1d9..84b8d73 100644
--- a/dialects/linux/dsock.c
+++ b/dialects/linux/dsock.c
@@ -4020,8 +4020,8 @@ process_proc_sock(p, pbr, s, ss, l, lss)
 	     * Store the local IPX address.
 	     */
 		len = strlen(ip->la);
-		if (len > nl)
-		    len = nl;
+		if (len > nl - 1)
+		    len = nl - 1;
 		(void) strncpy(cp, ip->la, len);
 		cp += len;
 		*cp = '\0';
@@ -4039,6 +4039,7 @@ process_proc_sock(p, pbr, s, ss, l, lss)
 		}
 		if (nl) {
 		    (void) snpf(cp, nl, "%s", ip->ra);
+		    len = strlen(ip->ra);
 		    cp += len;
 		    nl -= len;
 		}
-- 
2.27.0

