From 38e3b1d365cf0ed01e20e7dd03db8f4085944fd9 Mon Sep 17 00:00:00 2001 From: millert Date: Thu, 30 Apr 2015 21:18:45 +0000 Subject: [PATCH] Avoid NULL deref in fd_getfile_mode(); OK deraadt@ --- sys/kern/kern_descrip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.20.1