Module Name:    src
Committed By:   kalvisd
Date:           Mon Oct 21 05:39:48 UTC 2024

Modified Files:
        src/usr.sbin/mopd/common: file.c

Log Message:
mopd/common: when reading sections from an ELF image, signal end-of-image
if the current section index is advanced past the last section to process

This should address PR bin/19248

OK rin@


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/mopd/common/file.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mopd/common/file.c
diff -u src/usr.sbin/mopd/common/file.c:1.17 src/usr.sbin/mopd/common/file.c:1.18
--- src/usr.sbin/mopd/common/file.c:1.17	Tue Oct 27 17:16:24 2020
+++ src/usr.sbin/mopd/common/file.c	Mon Oct 21 05:39:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: file.c,v 1.17 2020/10/27 17:16:24 abs Exp $	*/
+/*	$NetBSD: file.c,v 1.18 2024/10/21 05:39:48 kalvisd Exp $	*/
 
 /*
  * Copyright (c) 1995-96 Mats O Jansson.  All rights reserved.
@@ -26,7 +26,7 @@
 
 #include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: file.c,v 1.17 2020/10/27 17:16:24 abs Exp $");
+__RCSID("$NetBSD: file.c,v 1.18 2024/10/21 05:39:48 kalvisd Exp $");
 #endif
 
 #include "os.h"
@@ -969,7 +969,8 @@ mopFileRead(struct dllist *dlslot, u_cha
 		if (dlslot->e_curpos >= (dlslot->e_sections[sec].s_loff +
 					 dlslot->e_sections[sec].s_fsize +
 					 dlslot->e_sections[sec].s_pad))
-			dlslot->e_cursec++;
+			if (++dlslot->e_cursec >= dlslot->e_nsec)
+				return (0);
 		break;
 
 	case IMAGE_TYPE_AOUT:

Reply via email to