This patch for fixing build warning caused by toolchain version-up
(applying GCC-9)
Change-Id: I3ddb98c7f8c79a03adfe8bcce2b6b58fa603a248
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
strlen(orig_icon_path) - (strlen(icon_filename) - 1),
"%s", orig_icon_path);
for (i = 0; i < 2; i++) {
strlen(orig_icon_path) - (strlen(icon_filename) - 1),
"%s", orig_icon_path);
for (i = 0; i < 2; i++) {
- snprintf(modified_iconpath, BUFSIZE - 1, "%s/%s%s",
+ ret = snprintf(modified_iconpath, BUFSIZE - 1, "%s/%s%s",
icon_path, dpi_path[i], icon_filename);
icon_path, dpi_path[i], icon_filename);
+ if (ret < 0 || ret > BUFSIZE -1) {
+ _LOGE("snprintf fail");
+ return -1;
+ }
if (access(modified_iconpath, F_OK) != -1) {
/* if exists, return modified icon path */
*new_icon_path = strdup(modified_iconpath);
if (access(modified_iconpath, F_OK) != -1) {
/* if exists, return modified icon path */
*new_icon_path = strdup(modified_iconpath);
char buffer[1024] = { 0 };
char temp_path[1024] = { 0 };
char *path = NULL;
char buffer[1024] = { 0 };
char temp_path[1024] = { 0 };
char *path = NULL;
if (type == NULL) {
_LOGE("invalid argument\n");
if (type == NULL) {
_LOGE("invalid argument\n");
- snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
+ ret = snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
+ if (ret < 0 || ret > sizeof(temp_path) -1) {
+ _LOGE("snprintf fail");
+ return NULL;
+ }
return strdup(temp_path);
}
return strdup(temp_path);
}
continue;
/* get glist of metadata key and value combination */
memset(buffer, 0x00, 1024);
continue;
/* get glist of metadata key and value combination */
memset(buffer, 0x00, 1024);
- snprintf(buffer, 1024, "%s/", md_key);
+ ret = snprintf(buffer, 1024, "%s/", md_key);
+ if (ret < 0 || ret > 1024) {
+ _LOGD("snprintf fail\n");
+ ret = -1;
+ goto END;
+ }
if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
if (md_detail == NULL) {
if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t));
if (md_detail == NULL) {
category = (const char *)category_tmp->data;
/* get glist of category key and value combination */
memset(buffer, 0x00, 1024);
category = (const char *)category_tmp->data;
/* get glist of category key and value combination */
memset(buffer, 0x00, 1024);
- snprintf(buffer, 1024, "%s/", category_key);
+ ret = snprintf(buffer, 1024, "%s/", category_key);
+ if (ret < 0 || ret > 1024) {
+ _LOGD("snprintf fail\n");
+ ret = -1;
+ goto END;
+ }
if ((category) && (strncmp(category, category_key, strlen(category_key)) == 0)) {
category_detail = (__category_t*) calloc(1, sizeof(__category_t));
if (category_detail == NULL) {
if ((category) && (strncmp(category, category_key, strlen(category_key)) == 0)) {
category_detail = (__category_t*) calloc(1, sizeof(__category_t));
if (category_detail == NULL) {
const char *locale, uid_t uid, char **query, GList **bind_params)
{
int joined = 0;
const char *locale, uid_t uid, char **query, GList **bind_params)
{
int joined = 0;
char *condition = NULL;
char buf[MAX_QUERY_LEN] = { '\0' };
char tmp_query[MAX_QUERY_LEN] = { '\0' };
char *condition = NULL;
char buf[MAX_QUERY_LEN] = { '\0' };
char tmp_query[MAX_QUERY_LEN] = { '\0' };
if (joined & E_PMINFO_APPINFO_JOIN_PRIVILEGE)
strncat(tmp_query, join_privilege, sizeof(tmp_query) - strlen(tmp_query) - 1);
if (joined & E_PMINFO_APPINFO_JOIN_PRIVILEGE)
strncat(tmp_query, join_privilege, sizeof(tmp_query) - strlen(tmp_query) - 1);
- strncat(tmp_query, buf, sizeof(tmp_query) - strlen(tmp_query) - 1);
-
- *query = strdup(tmp_query);
+ size = strlen(tmp_query) + strlen(buf) + 1;
+ *query = (char *)calloc(1, size);
if (*query == NULL)
return PMINFO_R_ERROR;
if (*query == NULL)
return PMINFO_R_ERROR;
+ snprintf(*query, size, "%s%s", tmp_query, buf);
char temp[PKG_STRING_LEN_MAX] = {'\0'};
GSList *link = NULL;
int prop = -1;
char temp[PKG_STRING_LEN_MAX] = {'\0'};
GSList *link = NULL;
int prop = -1;
prop = _pminfo_appinfo_convert_to_prop_str(property);
if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
prop = _pminfo_appinfo_convert_to_prop_str(property);
if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
_LOGI("Previous value is %s\n", prev);
filter->list = g_slist_delete_link(filter->list, link);
strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
_LOGI("Previous value is %s\n", prev);
filter->list = g_slist_delete_link(filter->list, link);
- snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
- strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
+ ret = snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
+ if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
+ _LOGE("snprintf fail\n");
+ free(node);
+ free(val);
+ return PMINFO_R_ERROR;
+ }
+ strncpy(val, temp, PKG_STRING_LEN_MAX);
_LOGI("New value is %s\n", val);
node->value = val;
filter->list = g_slist_append(filter->list, (gpointer)node);
memset(temp, '\0', PKG_STRING_LEN_MAX);
} else {
snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
_LOGI("New value is %s\n", val);
node->value = val;
filter->list = g_slist_append(filter->list, (gpointer)node);
memset(temp, '\0', PKG_STRING_LEN_MAX);
} else {
snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
- strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
+ strncpy(val, temp, PKG_STRING_LEN_MAX);
_LOGI("First value is %s\n", val);
node->value = val;
filter->list = g_slist_append(filter->list, (gpointer)node);
_LOGI("First value is %s\n", val);
node->value = val;
filter->list = g_slist_append(filter->list, (gpointer)node);
const char *locale, uid_t uid, char **query, GList **bind_params)
{
int joined = 0;
const char *locale, uid_t uid, char **query, GList **bind_params)
{
int joined = 0;
char buf[MAX_QUERY_LEN] = { '\0' };
char buf2[MAX_QUERY_LEN] = { '\0' };
char *condition = NULL;
char buf[MAX_QUERY_LEN] = { '\0' };
char buf2[MAX_QUERY_LEN] = { '\0' };
char *condition = NULL;
}
if (joined & E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO)
strncat(buf2, join_privilege_info, sizeof(buf2) - strlen(buf2) - 1);
}
if (joined & E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO)
strncat(buf2, join_privilege_info, sizeof(buf2) - strlen(buf2) - 1);
- strncat(buf2, buf, sizeof(buf2) - strlen(buf2) - 1);
+ size = strlen(buf2) + strlen(buf) + 1;
+ *query = (char *)calloc(1, size);
if (*query == NULL)
return PMINFO_R_ERROR;
if (*query == NULL)
return PMINFO_R_ERROR;
+ snprintf(*query, size, "%s%s", buf2, buf);
dir = opendir(traverse_path);
while ((ent = readdir(dir)) != NULL) {
dir = opendir(traverse_path);
while ((ent = readdir(dir)) != NULL) {
- snprintf(abs_dirname, PATH_MAX, "%s/%s", traverse_path,
+ ret = snprintf(abs_dirname, PATH_MAX, "%s/%s", traverse_path,
+ if (ret < 0 || ret > PATH_MAX) {
+ LOGE("snprintf fail");
+ closedir(dir);
+ return;
+ }
ret = stat(abs_dirname, &stats);
if (ret != 0) {
ret = stat(abs_dirname, &stats);
if (ret != 0) {