aboutsummaryrefslogtreecommitdiffstats
path: root/src/locale-root.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:49:09 +0200
commit60cd11786766ebc148b7ec088962dd6e112f8762 (patch)
tree212ec4b02261dbe8730a61b7bf66d8a61f9699ef /src/locale-root.c
parent16f014ef35b8355de1006891fe6920c8b51675fe (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/locale-root.c')
-rw-r--r--src/locale-root.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/locale-root.c b/src/locale-root.c
index fa620fee..4d141b86 100644
--- a/src/locale-root.c
+++ b/src/locale-root.c
@@ -47,7 +47,7 @@ static const char locales[] = "locales/";
struct locale_folder {
struct locale_folder *parent;
size_t length;
- char name[1];
+ char name[];
};
struct locale_container {
@@ -67,7 +67,7 @@ struct locale_search {
struct locale_root *root;
struct locale_search_node *head;
int refcount;
- char definition[1];
+ char definition[];
};
struct locale_root {
@@ -102,7 +102,7 @@ static int add_folder(struct locale_container *container, const char *name)
if (folders != NULL) {
container->folders = folders;
length = strlen(name);
- folders[count] = malloc(sizeof **folders + length);
+ folders[count] = malloc(sizeof **folders + 1 + length);
if (folders[count] != NULL) {
folders[count]->parent = NULL;
folders[count]->length = length;
@@ -362,7 +362,7 @@ static struct locale_search *create_search(struct locale_root *root, const char
struct locale_search_node *node;
/* allocate the structure */
- search = malloc(sizeof *search + length);
+ search = malloc(sizeof *search + 1 + length);
if (search == NULL) {
errno = ENOMEM;
} else {