Source-Changes-HG archive

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

[src/trunk]: src/external/mit/lua/dist/src lua: apply upstream bugfix for "Lo...



details:   https://anonhg.NetBSD.org/src/rev/d8322c5ac7d7
branches:  trunk
changeset: 374305:d8322c5ac7d7
user:      nikita <nikita%NetBSD.org@localhost>
date:      Mon Apr 17 21:17:57 2023 +0000

description:
lua: apply upstream bugfix for "Loading a corrupted binary file can segfault."

diffstat:

 external/mit/lua/dist/src/ldump.c   |  12 +++++++++++-
 external/mit/lua/dist/src/lundump.c |   4 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diffs (53 lines):

diff -r 41937fb29ab5 -r d8322c5ac7d7 external/mit/lua/dist/src/ldump.c
--- a/external/mit/lua/dist/src/ldump.c Mon Apr 17 20:37:43 2023 +0000
+++ b/external/mit/lua/dist/src/ldump.c Mon Apr 17 21:17:57 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ldump.c,v 1.10 2023/04/16 20:46:17 nikita Exp $        */
+/*     $NetBSD: ldump.c,v 1.11 2023/04/17 21:17:57 nikita Exp $        */
 
 /*
 ** Id: ldump.c 
@@ -14,6 +14,7 @@
 
 #ifndef _KERNEL
 #include <stddef.h>
+#include <limits.h>
 #endif /* _KERNEL */
 
 #include "lua.h"
@@ -59,8 +60,17 @@ static void dumpByte (DumpState *D, int 
 }
 
 
+#ifdef _KERNEL
 /* dumpInt Buff Size */
 #define DIBS    ((sizeof(size_t) * 8 / 7) + 1)
+#endif /* _KERNEL */
+#ifndef _KERNEL
+/*
+** 'dumpSize' buffer size: each byte can store up to 7 bits. (The "+6"
+** rounds up the division.)
+*/
+#define DIBS    ((sizeof(size_t) * CHAR_BIT + 6) / 7)
+#endif /* _KERNEL */
 
 static void dumpSize (DumpState *D, size_t x) {
   lu_byte buff[DIBS];
diff -r 41937fb29ab5 -r d8322c5ac7d7 external/mit/lua/dist/src/lundump.c
--- a/external/mit/lua/dist/src/lundump.c       Mon Apr 17 20:37:43 2023 +0000
+++ b/external/mit/lua/dist/src/lundump.c       Mon Apr 17 21:17:57 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lundump.c,v 1.9 2023/04/16 20:46:17 nikita Exp $       */
+/*     $NetBSD: lundump.c,v 1.10 2023/04/17 21:17:57 nikita Exp $      */
 
 /*
 ** Id: lundump.c 
@@ -254,6 +254,8 @@ static void loadDebug (LoadState *S, Pro
     f->locvars[i].endpc = loadInt(S);
   }
   n = loadInt(S);
+  if (n != 0)  /* does it have debug information? */
+    n = f->sizeupvalues;  /* must be this many */
   for (i = 0; i < n; i++)
     f->upvalues[i].name = loadStringN(S, f);
 }



Home | Main Index | Thread Index | Old Index