From: millert Date: Thu, 30 Apr 2015 21:18:45 +0000 (+0000) Subject: Avoid NULL deref in fd_getfile_mode(); OK deraadt@ X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=38e3b1d365cf0ed01e20e7dd03db8f4085944fd9;p=openbsd Avoid NULL deref in fd_getfile_mode(); OK deraadt@ --- diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 2c8955c4d01..93d6a9c4cfe 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.118 2015/04/30 09:20:51 mpi Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.119 2015/04/30 21:18:45 millert Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -201,7 +201,7 @@ fd_getfile_mode(struct filedesc *fdp, int fd, int mode) fp = fd_getfile(fdp, fd); - if ((fp->f_flag & mode) == 0) + if (fp == NULL || (fp->f_flag & mode) == 0) return (NULL); return (fp);