Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/ibcs2 Check for NUL termination within the buffer...



details:   https://anonhg.NetBSD.org/src/rev/d1515498f547
branches:  trunk
changeset: 825704:d1515498f547
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Jul 28 15:47:23 2017 +0000

description:
Check for NUL termination within the buffer we have.

>From Ilja Van Sprundel.

diffstat:

 sys/compat/ibcs2/ibcs2_exec_coff.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 8057ac4ad3e5 -r d1515498f547 sys/compat/ibcs2/ibcs2_exec_coff.c
--- a/sys/compat/ibcs2/ibcs2_exec_coff.c        Fri Jul 28 15:40:38 2017 +0000
+++ b/sys/compat/ibcs2/ibcs2_exec_coff.c        Fri Jul 28 15:47:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_exec_coff.c,v 1.26 2013/10/25 14:46:35 martin Exp $      */
+/*     $NetBSD: ibcs2_exec_coff.c,v 1.27 2017/07/28 15:47:23 riastradh Exp $   */
 
 /*
  * Copyright (c) 1994, 1995, 1998 Scott Bartram
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec_coff.c,v 1.26 2013/10/25 14:46:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec_coff.c,v 1.27 2017/07/28 15:47:23 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -465,7 +465,8 @@
                        /* path_index = slhdr->path_index * sizeof(long); */
                        entry_len = slhdr->entry_len * sizeof(long);
 
-                       if (entry_len > len) {
+                       if (entry_len > len ||
+                           strnlen(slhdr->sl_name, entry_len) == entry_len) {
                                free(tbuf, M_TEMP);
                                return ENOEXEC;
                        }



Home | Main Index | Thread Index | Old Index