Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 Change xgetblk to detect cases where the...



details:   https://anonhg.NetBSD.org/src/rev/7cccae340a0a
branches:  trunk
changeset: 533352:7cccae340a0a
user:      jmc <jmc%NetBSD.org@localhost>
date:      Fri Jun 28 05:03:55 2002 +0000

description:
Change xgetblk to detect cases where the requested size is more than mblklen.
(generally it's 20k). Adjust mblklen temporarily to the size of the block
required and allocate one. This avoids coredumps when mapping in identifiers
that have huge values. (In my example it was a char[] for a 640k pixmap).

diffstat:

 usr.bin/xlint/lint1/mem1.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r 05263a78c877 -r 7cccae340a0a usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c        Fri Jun 28 03:38:13 2002 +0000
+++ b/usr.bin/xlint/lint1/mem1.c        Fri Jun 28 05:03:55 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem1.c,v 1.7 2002/01/31 19:36:54 tv Exp $      */
+/*     $NetBSD: mem1.c,v 1.8 2002/06/28 05:03:55 jmc Exp $     */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.7 2002/01/31 19:36:54 tv Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.8 2002/06/28 05:03:55 jmc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -196,11 +196,18 @@
 {
        mbl_t   *mb;
        void    *p;
+       size_t  t = 0;
 
        s = ALIGN(s);
        if ((mb = *mbp) == NULL || mb->nfree < s) {
                if ((mb = frmblks) == NULL) {
+                       if (s > mblklen) {
+                               t = mblklen;
+                               mblklen = s;
+                       }
                        mb = xnewblk();
+                       if (t)
+                               mblklen = t;
                        (void)memset(mb->blk, 0, mb->size);
                } else {
                        frmblks = mb->nxt;



Home | Main Index | Thread Index | Old Index