Module Name: src
Committed By: martin
Date: Thu Sep 12 20:30:58 UTC 2013
Modified Files:
src/sys/dev/i2c: i2c_exec.c
Log Message:
Fix evil "sizeof(void*)" botch
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/i2c_exec.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/i2c/i2c_exec.c
diff -u src/sys/dev/i2c/i2c_exec.c:1.8 src/sys/dev/i2c/i2c_exec.c:1.9
--- src/sys/dev/i2c/i2c_exec.c:1.8 Sun Apr 22 14:10:36 2012
+++ src/sys/dev/i2c/i2c_exec.c Thu Sep 12 20:30:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c_exec.c,v 1.8 2012/04/22 14:10:36 pgoyette Exp $ */
+/* $NetBSD: i2c_exec.c,v 1.9 2013/09/12 20:30:58 martin Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.8 2012/04/22 14:10:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.9 2013/09/12 20:30:58 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -90,8 +90,9 @@ iic_exec(i2c_tag_t tag, i2c_op_t op, i2c
case 2:
break;
default:
- memcpy(data, vbuf, sizeof(vbuf));
- data[sizeof(vbuf)] = iic_smbus_pec(2, b, data);
+ KASSERT(buflen+1 < sizeof(data));
+ memcpy(data, vbuf, buflen);
+ data[buflen] = iic_smbus_pec(2, b, data);
buflen++;
break;
}