Source-Changes-HG archive

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

[src/trunk]: src/crypto/dist/kame/libipsec correct unsafe realloc().



details:   https://anonhg.NetBSD.org/src/rev/f2c1c3d43a1e
branches:  trunk
changeset: 552776:f2c1c3d43a1e
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Oct 02 19:52:43 2003 +0000

description:
correct unsafe realloc().

diffstat:

 crypto/dist/kame/libipsec/policy_parse.y |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 8c524d93f646 -r f2c1c3d43a1e crypto/dist/kame/libipsec/policy_parse.y
--- a/crypto/dist/kame/libipsec/policy_parse.y  Thu Oct 02 19:38:59 2003 +0000
+++ b/crypto/dist/kame/libipsec/policy_parse.y  Thu Oct 02 19:52:43 2003 +0000
@@ -1,4 +1,4 @@
-/*     $KAME: policy_parse.y,v 1.14 2003/06/27 03:39:20 itojun Exp $   */
+/*     $KAME: policy_parse.y,v 1.15 2003/10/02 19:37:49 itojun Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -320,17 +320,19 @@
 {
        struct sadb_x_ipsecrequest *p;
        int reqlen;
+       caddr_t n;
 
        reqlen = sizeof(*p)
                + (src ? src->sa_len : 0)
                + (dst ? dst->sa_len : 0);
-       tlen += reqlen;         /* increment to total length */
 
-       pbuf = realloc(pbuf, tlen);
+       n = realloc(pbuf, tlen + reqlen);
        if (pbuf == NULL) {
                __ipsec_errcode = EIPSEC_NO_BUFS;
                return -1;
        }
+       tlen += reqlen;
+       pbuf = n;
        p = (struct sadb_x_ipsecrequest *)&pbuf[offset];
        p->sadb_x_ipsecrequest_len = reqlen;
        p->sadb_x_ipsecrequest_proto = p_protocol;



Home | Main Index | Thread Index | Old Index