Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpvfs Avoid copying zero-sized objects (f...
details: https://anonhg.NetBSD.org/src/rev/e728ff4a6a1d
branches: trunk
changeset: 1008861:e728ff4a6a1d
user: kamil <kamil%NetBSD.org@localhost>
date: Sat Apr 04 19:24:51 2020 +0000
description:
Avoid copying zero-sized objects (from the NULL address)
Detected with UBSan
diffstat:
sys/rump/librump/rumpvfs/rumpfs.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diffs (38 lines):
diff -r bfdc2e6f94b5 -r e728ff4a6a1d sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Sat Apr 04 19:02:53 2020 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Sat Apr 04 19:24:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpfs.c,v 1.154 2020/01/17 20:08:09 ad Exp $ */
+/* $NetBSD: rumpfs.c,v 1.155 2020/04/04 19:24:51 kamil Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.154 2020/01/17 20:08:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.155 2020/04/04 19:24:51 kamil Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -977,7 +977,8 @@
return ENOSPC;
copylen = MIN(rn->rn_dlen, newlen);
- memcpy(newdata, rn->rn_data, copylen);
+ if (copylen > 0)
+ memcpy(newdata, rn->rn_data, copylen);
memset((char *)newdata + copylen, 0, newlen - copylen);
if ((rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) {
@@ -1492,7 +1493,8 @@
return ENOSPC;
rn->rn_dlen = newlen;
memset(rn->rn_data, 0, newlen);
- memcpy(rn->rn_data, olddata, oldlen);
+ if (oldlen > 0)
+ memcpy(rn->rn_data, olddata, oldlen);
allocd = true;
uvm_vnp_setsize(vp, newlen);
}
Home |
Main Index |
Thread Index |
Old Index