about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2006-12-17 22:52:43 +0000
committerFlorian Westphal <fw@strlen.de>2006-12-17 22:52:43 +0000
commit3f1e03edd93bcbb1643291a4e0e462d1dc0c7019 (patch)
tree35221b20db16500bd64d2daeb02aa38b118299e8 /src
parent23e7f7f0dd55d140aca91ace6102e714cba5bbd0 (diff)
downloadngircd-3f1e03edd93bcbb1643291a4e0e462d1dc0c7019.tar.gz
ngircd-3f1e03edd93bcbb1643291a4e0e462d1dc0c7019.zip
fix possibe buffer-off-by one
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/array.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ngircd/array.c b/src/ngircd/array.c
index bc28d042..1342c670 100644
--- a/src/ngircd/array.c
+++ b/src/ngircd/array.c
@@ -12,7 +12,7 @@
 
 #include "array.h"
 
-static char UNUSED id[] = "$Id: array.c,v 1.12 2006/09/30 21:49:46 fw Exp $";
+static char UNUSED id[] = "$Id: array.c,v 1.13 2006/12/17 22:52:43 fw Exp $";
 
 #include <assert.h>
 
@@ -247,19 +247,21 @@ void *
 array_get(array * a, size_t membersize, size_t pos)
 {
 	size_t totalsize;
+	size_t posplus1 = pos + 1;
 
 	assert(membersize > 0);
 	assert(a != NULL);
 
-	if (array_UNUSABLE(a))
+	if (!posplus1 || array_UNUSABLE(a))
 		return NULL;
 
-	if (!safemult_sizet(pos, membersize, &totalsize))
+	if (!safemult_sizet(posplus1, membersize, &totalsize))
 		return NULL;
 
 	if (a->allocated < totalsize)
 		return NULL;
 
+	totalsize = pos * membersize;
 	return a->mem + totalsize;
 }