X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Flocale-root.c;h=0cf14eeaa569ac31c45835cf97714d21512adf89;hb=65353dce81a629e042800bb7b86fcd869a76727e;hp=38d488dc42a4d4dd2aa5d02d868fd06dd9159ad6;hpb=d7933c0f61a3316cc3d1ca7e74d30e193de2f612;p=src%2Fapp-framework-binder.git diff --git a/src/locale-root.c b/src/locale-root.c index 38d488dc..0cf14eea 100644 --- a/src/locale-root.c +++ b/src/locale-root.c @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright (C) 2015-2020 "IoT.bzh" author: José Bollo @@ -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; @@ -157,7 +157,7 @@ static struct locale_folder *search_folder(struct locale_container *container, c */ static int init_container(struct locale_container *container, int dirfd) { - int rc, sfd; + int rc = 0, sfd; DIR *dir; struct dirent *dent; struct stat st; @@ -193,7 +193,8 @@ static int init_container(struct locale_container *container, int dirfd) return -1; break; } - if (dent->d_type == DT_DIR || (dent->d_type == DT_UNKNOWN && fstatat(sfd, dent->d_name, &st, 0) == 0 && S_ISDIR(st.st_mode))) { + rc = fstatat(sfd, dent->d_name, &st, 0); + if (rc == 0 && S_ISDIR(st.st_mode)) { /* directory aka folder */ if (dent->d_name[0] == '.' && (dent->d_name[1] == 0 || (dent->d_name[1] == '.' && dent->d_name[2] == 0))) { /* nothing to do for special directories, basic detection, improves if needed */ @@ -361,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 {