diff options
author | Nico Golde <nico@ngolde.de> | 2012-09-21 17:44:58 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-09-27 13:45:03 +0200 |
commit | 0262d3ff9fadbc6300e4146101539b4f07fcf4b8 (patch) | |
tree | fd8507d092fd91fd616dc364b944425a294cb06c | |
parent | 5b67a04a34cb2e6ed2ee441b87bda12dca39626f (diff) |
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.
-rw-r--r-- | src/logging.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/logging.c b/src/logging.c index 0816570e..f58265f7 100644 --- a/src/logging.c +++ b/src/logging.c @@ -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; |