Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/fs/lib/libsyspuffs CID 274829: Check error from fd_...



details:   https://anonhg.NetBSD.org/src/rev/d0de1eb464a3
branches:  trunk
changeset: 338104:d0de1eb464a3
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 10 14:00:42 2015 +0000

description:
CID 274829: Check error from fd_getfile to avoid NULL deref immediately
after.

diffstat:

 sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (46 lines):

diff -r 907d1e7b971e -r d0de1eb464a3 sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c
--- a/sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c      Sun May 10 13:24:11 2015 +0000
+++ b/sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c      Sun May 10 14:00:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_rumpglue.c,v 1.13 2013/04/30 00:03:53 pooka Exp $        */
+/*     $NetBSD: puffs_rumpglue.c,v 1.14 2015/05/10 14:00:42 christos Exp $     */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.13 2013/04/30 00:03:53 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.14 2015/05/10 14:00:42 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -85,8 +85,11 @@
 
                off = 0;
                fp = fd_getfile(pap->fpfd);
-               error = dofileread(pap->fpfd, fp, buf, BUFSIZE,
-                   &off, 0, &rv);
+               if (fp == NULL)
+                       error = EINVAL;
+               else
+                       error = dofileread(pap->fpfd, fp, buf, BUFSIZE,
+                           &off, 0, &rv);
                if (error) {
                        if (error == ENOENT && inited == 0)
                                goto retry;
@@ -161,8 +164,11 @@
                off = 0;
                rv = 0;
                fp = fd_getfile(pap->fpfd);
-               error = dofilewrite(pap->fpfd, fp, buf, phdr->pth_framelen,
-                   &off, 0, &rv);
+               if (fp == NULL)
+                       error = EINVAL;
+               else
+                       error = dofilewrite(pap->fpfd, fp, buf,
+                           phdr->pth_framelen, &off, 0, &rv);
                if (error == ENXIO)
                        goto out;
                KASSERT(rv == phdr->pth_framelen);



Home | Main Index | Thread Index | Old Index