Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/msdosfs Use KASSERT for conditions that cannot be met...
details: https://anonhg.NetBSD.org/src/rev/d950df219872
branches: trunk
changeset: 343939:d950df219872
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Mar 06 07:33:25 2016 +0000
description:
Use KASSERT for conditions that cannot be met with current parameters.
diffstat:
sys/fs/msdosfs/msdosfs_conv.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diffs (45 lines):
diff -r 7761d1d2256b -r d950df219872 sys/fs/msdosfs/msdosfs_conv.c
--- a/sys/fs/msdosfs/msdosfs_conv.c Sun Mar 06 04:19:51 2016 +0000
+++ b/sys/fs/msdosfs/msdosfs_conv.c Sun Mar 06 07:33:25 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_conv.c,v 1.15 2016/02/06 10:40:58 mlelstv Exp $ */
+/* $NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $ */
/*-
* Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -52,8 +52,13 @@
#include "nbtool_config.h"
#endif
+#ifndef _KERNEL
+#include <assert.h>
+#define KASSERT(x) assert(x)
+#endif
+
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.15 2016/02/06 10:40:58 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $");
/*
* System include files.
@@ -685,8 +690,8 @@
len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf))
: ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
- if ((size_t)len > sizeof(dp->d_name) - 1)
- return -1;
+ KASSERT(len >= 0);
+ KASSERT((size_t)len <= MIN(sizeof(buf), sizeof(dp->d_name)-1));
/*
* Prepend name segment to directory entry
@@ -702,6 +707,9 @@
*namlen += len;
if (*namlen > sizeof(dp->d_name) - 1)
*namlen = sizeof(dp->d_name) - 1;
+
+ KASSERT(*namlen >= len);
+
memmove(&dp->d_name[len], &dp->d_name[0], *namlen - len);
memcpy(dp->d_name, buf, len);
Home |
Main Index |
Thread Index |
Old Index