Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs Don't panic for a negative offset, just fail the oper...
details: https://anonhg.NetBSD.org/src/rev/b9b565d31ad9
branches: trunk
changeset: 368735:b9b565d31ad9
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Jul 31 13:08:18 2022 +0000
description:
Don't panic for a negative offset, just fail the operation with EINVAL.
diffstat:
sys/fs/sysvbfs/sysvbfs_vnops.c | 8 +++++---
sys/fs/v7fs/v7fs_vnops.c | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diffs (60 lines):
diff -r 0656af2f121c -r b9b565d31ad9 sys/fs/sysvbfs/sysvbfs_vnops.c
--- a/sys/fs/sysvbfs/sysvbfs_vnops.c Sun Jul 31 13:01:16 2022 +0000
+++ b/sys/fs/sysvbfs/sysvbfs_vnops.c Sun Jul 31 13:08:18 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs_vnops.c,v 1.68 2021/10/20 03:08:17 thorpej Exp $ */
+/* $NetBSD: sysvbfs_vnops.c,v 1.69 2022/07/31 13:08:18 mlelstv Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.68 2021/10/20 03:08:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.69 2022/07/31 13:08:18 mlelstv Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -632,7 +632,9 @@
uio->uio_offset, uio->uio_resid);
KDASSERT(vp->v_type == VDIR);
- KDASSERT(uio->uio_offset >= 0);
+
+ if (uio->uio_offset < 0)
+ return EINVAL;
dp = malloc(sizeof(struct dirent), M_BFS, M_WAITOK | M_ZERO);
diff -r 0656af2f121c -r b9b565d31ad9 sys/fs/v7fs/v7fs_vnops.c
--- a/sys/fs/v7fs/v7fs_vnops.c Sun Jul 31 13:01:16 2022 +0000
+++ b/sys/fs/v7fs/v7fs_vnops.c Sun Jul 31 13:08:18 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vnops.c,v 1.37 2022/05/22 11:27:36 andvar Exp $ */
+/* $NetBSD: v7fs_vnops.c,v 1.38 2022/07/31 13:08:19 mlelstv Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.37 2022/05/22 11:27:36 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.38 2022/07/31 13:08:19 mlelstv Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -996,9 +996,11 @@
DPRINTF("offset=%zu residue=%zu\n", uio->uio_offset, uio->uio_resid);
KDASSERT(vp->v_type == VDIR);
- KDASSERT(uio->uio_offset >= 0);
KDASSERT(v7fs_inode_isdir(inode));
+ if (uio->uio_offset < 0)
+ return EINVAL;
+
struct v7fs_readdir_arg arg;
arg.start = uio->uio_offset / sizeof(*dp);
arg.end = arg.start + uio->uio_resid / sizeof(*dp);
Home |
Main Index |
Thread Index |
Old Index