summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-07-31 12:27:02 +0200
committerAnand Avati <avati@redhat.com>2012-08-19 09:42:43 -0700
commit7daa85508314838ce8f0c2cb731827d0f92eb5ee (patch)
tree342e6003ac38cce37cbd020ba720db7fb536c29d /xlators/features
parentd22726cf8a76167acd63a9af7233b798a1e484f2 (diff)
gsyncd: don't use void* arithmetic; don't leak upon OOM; remove cast
(duplexpand): Ignore risk of overflow in computation of the realloc object count, since we'd need a string with 2^62 space-separated tokens to trigger that (that's w/64-bit size_t; w/32-bit it'd be easier, but still improbable). Change-Id: If4521afe7b46110742991dd0ee234284ef8970df BUG: 846755 Signed-off-by: Jim Meyering <meyering@redhat.com> Reviewed-on: http://review.gluster.com/3793 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/marker/utils/src/gsyncd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/xlators/features/marker/utils/src/gsyncd.c b/xlators/features/marker/utils/src/gsyncd.c
index 3f4c2c4b38a..63619b43c68 100644
--- a/xlators/features/marker/utils/src/gsyncd.c
+++ b/xlators/features/marker/utils/src/gsyncd.c
@@ -46,12 +46,14 @@ static int
duplexpand (void **buf, size_t tsiz, size_t *len)
{
size_t osiz = tsiz * *len;
-
- *buf = realloc (*buf, osiz << 1);
- if (!*buf)
+ char *p = realloc (*buf, osiz << 1);
+ if (!p) {
+ free(*buf);
return -1;
+ }
- memset ((char *)*buf + osiz, 0, osiz);
+ memset (p + osiz, 0, osiz);
+ *buf = p;
*len <<= 1;
return 0;