summaryrefslogtreecommitdiffstats
path: root/src/afb-stub-ws.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-04-02 16:49:09 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2019-04-02 16:57:17 +0200
commitbc8929bec96e81a7f487d5689f52335b435f0e3e (patch)
treeeadbd57ccad8ad7ebad26b4ebdc5db66d6faf442 /src/afb-stub-ws.c
parent75a6b9e42432e3503a69013624c786af35aed7af (diff)
Fix false ***buffer overflow*** detection
The compiling option __FORTIFY_SOURCE=2 introduced a false ***buffer overflow*** detection when the flexible array 'pattern' was initilized in globset. The compiler is only complaining when the array is in a struct that is in a struct like struct { ...; struct { ...; char name[1]; }} To avoid these false detections, it is enougth to ellipsese the dimension of the array. Seems to be the now standard way of declaring flexible arrays when it was before an extension. So now: struct { ...; struct { ...; char name[]; }} works even when __FORTIFY_SOURCE=2. Bug-AGL: SPEC-2292 Change-Id: I4b4a5df505a5357f92b9ab1657175911198ca582 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-stub-ws.c')
-rw-r--r--src/afb-stub-ws.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c
index eab897b0..0e777f5a 100644
--- a/src/afb-stub-ws.c
+++ b/src/afb-stub-ws.c
@@ -145,7 +145,7 @@ struct afb_stub_ws
uint8_t is_client;
/* the api name */
- char apiname[1];
+ char apiname[];
};
static struct afb_proto_ws *afb_stub_ws_create_proto(struct afb_stub_ws *stubws, struct fdev *fdev, uint8_t server);
@@ -673,7 +673,7 @@ static struct afb_stub_ws *afb_stub_ws_create(struct fdev *fdev, const char *api
{
struct afb_stub_ws *stubws;
- stubws = calloc(1, sizeof *stubws + strlen(apiname));
+ stubws = calloc(1, sizeof *stubws + 1 + strlen(apiname));
if (stubws == NULL)
errno = ENOMEM;
else {