afb-export: Fix heap corruption 05/20905/1
authorJosé Bollo <jose.bollo@iot.bzh>
Thu, 4 Apr 2019 13:28:03 +0000 (15:28 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Thu, 4 Apr 2019 13:34:02 +0000 (15:34 +0200)
The allocated size wasn't correct when 'path'
was used. The effect be unseen depending on
size and alignment of heap chunks.

Change-Id: Id9f85a0078028319491b51bc3e11cd51e4bc3755
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-export.c

index b46e6a0..2c6522f 100644 (file)
@@ -1372,7 +1372,7 @@ static struct afb_export *create(
                        return NULL;
        }
        lenapi = strlen(apiname);
-       export = calloc(1, sizeof *export + 1 + lenapi + (path == apiname || !path ? 0 : strlen(path)));
+       export = calloc(1, sizeof *export + 1 + lenapi + (path == apiname || !path ? 0 : 1 + strlen(path)));
        if (!export)
                errno = ENOMEM;
        else {