Source-Changes-HG archive

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

[src/trunk]: src/sys/netsmb Reject allocations for too-small buffers from use...



details:   https://anonhg.NetBSD.org/src/rev/19c223a78aa6
branches:  trunk
changeset: 825693:19c223a78aa6
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Jul 28 14:20:46 2017 +0000

description:
Reject allocations for too-small buffers from userland.

>From Ilja Van Sprundel.

diffstat:

 sys/netsmb/smb_usr.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 5a88c7243d8c -r 19c223a78aa6 sys/netsmb/smb_usr.c
--- a/sys/netsmb/smb_usr.c      Fri Jul 28 14:16:29 2017 +0000
+++ b/sys/netsmb/smb_usr.c      Fri Jul 28 14:20:46 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smb_usr.c,v 1.16 2009/03/18 16:00:24 cegger Exp $      */
+/*     $NetBSD: smb_usr.c,v 1.17 2017/07/28 14:20:46 riastradh Exp $   */
 
 /*
  * Copyright (c) 2000-2001 Boris Popov
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_usr.c,v 1.16 2009/03/18 16:00:24 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_usr.c,v 1.17 2017/07/28 14:20:46 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -75,11 +75,17 @@
                SMBERROR(("no local charset ?\n"));
                return EINVAL;
        }
+       if (dp->ioc_svlen < sizeof(*spec->sap))
+               return EINVAL;
 
        spec->sap = smb_memdupin(dp->ioc_server, dp->ioc_svlen);
        if (spec->sap == NULL)
                return ENOMEM;
        if (dp->ioc_local) {
+               if (dp->ioc_lolen < sizeof(*spec->lap)) {
+                       smb_usr_vcspec_free(spec);
+                       return ENOMEM;
+               }
                spec->lap = smb_memdupin(dp->ioc_local, dp->ioc_lolen);
                if (spec->lap == NULL) {
                        smb_usr_vcspec_free(spec);



Home | Main Index | Thread Index | Old Index