diff options
Diffstat (limited to 'src/sh_error.c')
-rw-r--r-- | src/sh_error.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/sh_error.c b/src/sh_error.c index 5ec934b..82ee3c8 100644 --- a/src/sh_error.c +++ b/src/sh_error.c @@ -243,6 +243,7 @@ void sh_error_dbg_switch(void) static int sh_error_set_classmask (const char * str, int * facility_mask) { char * p; + char * q; int num = 0; unsigned int i; size_t len; @@ -289,6 +290,8 @@ static int sh_error_set_classmask (const char * str, int * facility_mask) if (p == NULL) break; + q = p; while (*q != '\0') { *q = toupper( (int) *q); ++q; } + for (i = 0; i < SH_CLA_MAX; ++i) { if (i < SH_CLA_RAW_MAX) { @@ -494,15 +497,20 @@ int sh_error_convert_level (const char * str_s) { int i; int level = (-1); + char * tmp; + char * q; SL_ENTER(_("sh_error_convert_level")); if (str_s == NULL) SL_RETURN( -1, _("sh_error_convert_level")); + q = sh_util_strdup(str_s); + tmp = q; while (*tmp != '\0') { *tmp = tolower( (int) *tmp); ++tmp; } + for (i = 0; i < SH_EEF_MAX; ++i) { - if (0 == sl_strncmp(str_s, _(eef_tab[i].str), + if (0 == sl_strncmp(q, _(eef_tab[i].str), sl_strlen(eef_tab[i].str))) { level = eef_tab[i].val; @@ -510,6 +518,7 @@ int sh_error_convert_level (const char * str_s) } } + SH_FREE(q); SL_RETURN( level, _("sh_error_convert_level")); } @@ -553,10 +562,17 @@ int sh_error_set_level(const char * str_in, int * facility) register int i, j, f = BAD; int old_facility; - const char * str_s = str_in; + char * str_s; + char * str_orig; + char * tmp; SL_ENTER(_("sh_error_set_level")); + str_s = sh_util_strdup(str_in); + str_orig = str_s; + + tmp = str_s; while (*tmp != '\0') { *tmp = tolower( (int) *tmp); ++tmp; } + if (IsInitialized == BAD) (void) sh_error_init(); @@ -649,6 +665,7 @@ int sh_error_set_level(const char * str_in, int * facility) if (!str_s) { + if (str_orig) SH_FREE(str_orig); SL_RETURN ((-1), _("sh_error_set_level")); } /* skip to end of string @@ -674,10 +691,12 @@ int sh_error_set_level(const char * str_in, int * facility) *facility = old_facility; sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS, _("priority"), str_in); + SH_FREE(str_orig); SL_RETURN (-1, _("sh_error_set_level")); } compute_flag_err_debug(); compute_flag_err_info(); + SH_FREE(str_orig); SL_RETURN (0, _("sh_error_set_level")); } @@ -1422,7 +1441,7 @@ void sh_error_handle (int sev1, const char * file, long line, SH_FREE( lmsg->msg ); sh_replace_free(hexmsg); - memset ( lmsg, (int) '\0', sizeof(struct _log_t) ); + memset ( lmsg, 0, sizeof(struct _log_t) ); MUNLOCK( (char *) lmsg, sizeof(struct _log_t) ); SH_FREE( lmsg ); own_block = 0; |