logging.c: Do not crash on empty category name

log_parse_category_mask(), skip log category name right away if
name is NULL to prevent passing a NULL ptr to strlen.
This commit is contained in:
Nico Golde 2012-09-21 17:44:58 +02:00 committed by Holger Hans Peter Freyther
parent 5b67a04a34
commit 0262d3ff9f
1 changed files with 7 additions and 5 deletions

View File

@ -175,17 +175,19 @@ void log_parse_category_mask(struct log_target* target, const char *_mask)
category_token = strtok(mask, ":");
do {
for (i = 0; i < osmo_log_info->num_cat; ++i) {
size_t length, cat_length;
char* colon = strstr(category_token, ",");
int length = strlen(category_token);
int cat_length = strlen(osmo_log_info->cat[i].name);
if (!osmo_log_info->cat[i].name)
continue;
length = strlen(category_token);
cat_length = strlen(osmo_log_info->cat[i].name);
/* Use longest length not to match subocurrences. */
if (cat_length > length)
length = cat_length;
if (!osmo_log_info->cat[i].name)
continue;
if (colon)
length = colon - category_token;