From d3af725dcc0a757709c1a731f1ed8a82b8c5823f Mon Sep 17 00:00:00 2001 From: TAKAHASHI Tamotsu Date: Thu, 1 Jun 2017 13:33:21 -0700 Subject: [PATCH] Fix "format string is not a string literal" warnings. (closes #3949) Mutt calls msgfmt with '-c' to verify that translation format strings match, but it is still safer to indirect strings with no formatting through %s. --- hook.c | 2 +- init.c | 16 ++++++++-------- main.c | 2 +- mutt_ssl.c | 4 ++-- ncrypt/crypt_gpgme.c | 6 +++--- pattern.c | 6 +++--- pop.c | 4 ++-- pop_auth.c | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hook.c b/hook.c index 4382469d6..8a0d282d6 100644 --- a/hook.c +++ b/hook.c @@ -307,7 +307,7 @@ int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, { if (current_hook_type) { - snprintf(err->data, err->dsize, + snprintf(err->data, err->dsize, "%s", _("unhook: Can't do unhook * from within a hook.")); return -1; } diff --git a/init.c b/init.c index 0b978c9b0..049f4d654 100644 --- a/init.c +++ b/init.c @@ -72,7 +72,7 @@ #define CHECK_PAGER \ if ((CurrentMenu == MENU_PAGER) && (idx >= 0) && (MuttVars[idx].flags & R_RESORT)) \ { \ - snprintf(err->data, err->dsize, _("Not available in this menu.")); \ + snprintf(err->data, err->dsize, "%s", _("Not available in this menu.")); \ return -1; \ } @@ -734,8 +734,8 @@ static int add_to_replace_list(struct ReplaceList **list, const char *pat, if (t->nmatch > t->rx->rx->re_nsub) { - snprintf(err->data, err->dsize, _("Not enough subexpressions for " - "template")); + snprintf(err->data, err->dsize, "%s", _("Not enough subexpressions for " + "template")); remove_from_replace_list(list, pat); return -1; } @@ -2423,13 +2423,13 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, { if (query || unset || inv) { - snprintf(err->data, err->dsize, _("prefix is illegal with reset")); + snprintf(err->data, err->dsize, "%s", _("prefix is illegal with reset")); return -1; } if (*s->dptr == '=') { - snprintf(err->data, err->dsize, _("value is illegal with reset")); + snprintf(err->data, err->dsize, "%s", _("value is illegal with reset")); return -1; } @@ -2437,7 +2437,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, { if (CurrentMenu == MENU_PAGER) { - snprintf(err->data, err->dsize, _("Not available in this menu.")); + snprintf(err->data, err->dsize, "%s", _("Not available in this menu.")); return -1; } for (idx = 0; MuttVars[idx].option; idx++) @@ -2464,7 +2464,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, { if (unset || inv || query) { - snprintf(err->data, err->dsize, _("Usage: set variable=yes|no")); + snprintf(err->data, err->dsize, "%s", _("Usage: set variable=yes|no")); return -1; } @@ -2476,7 +2476,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, unset = 1; else { - snprintf(err->data, err->dsize, _("Usage: set variable=yes|no")); + snprintf(err->data, err->dsize, "%s", _("Usage: set variable=yes|no")); return -1; } } diff --git a/main.c b/main.c index 7eaca751f..92d00218a 100644 --- a/main.c +++ b/main.c @@ -309,7 +309,7 @@ int main(int argc, char **argv, char **env) } printf(_("Debugging at level %d.\n"), debuglevel_cmdline); #else - printf(_("DEBUG was not defined during compilation. -d Ignored.\n")); + printf("%s", _("DEBUG was not defined during compilation. -d Ignored.\n")); #endif break; diff --git a/mutt_ssl.c b/mutt_ssl.c index 8070afdc8..2b7384c9a 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -351,7 +351,7 @@ static void x509_fingerprint(char *s, int l, X509 *cert, const EVP_MD *(*hashfun if (!X509_digest(cert, hashfunc(), md, &n)) { - snprintf(s, l, _("[unable to calculate]")); + snprintf(s, l, "%s", _("[unable to calculate]")); } else { @@ -808,7 +808,7 @@ static int interactive_check_cert(X509 *cert, int idx, int len, SSL *ssl, int al x509_get_part(x509_issuer, part[u])); row++; - snprintf(menu->dialog[row++], SHORT_STRING, _("This certificate is valid")); + snprintf(menu->dialog[row++], SHORT_STRING, "%s", _("This certificate is valid")); snprintf(menu->dialog[row++], SHORT_STRING, _(" from %s"), asn1time_to_string(X509_get_notBefore(cert))); snprintf(menu->dialog[row++], SHORT_STRING, _(" to %s"), diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 0331813f8..3c3d6ab00 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -3381,7 +3381,7 @@ static void print_key_info(gpgme_key_t key, FILE *fp) fprintf(fp, _("Key Type ..: %s, %lu bit %s\n"), s2, aval, s); /* L10N: DOTFILL */ - fprintf(fp, _("Key Usage .: ")); + fprintf(fp, "%s", _("Key Usage .: ")); delim = ""; if (key_check_cap(key, KEY_CAP_CAN_ENCRYPT)) @@ -3450,7 +3450,7 @@ static void print_key_info(gpgme_key_t key, FILE *fp) if (s) { /* L10N: DOTFILL */ - fprintf(fp, _("Issued By .: ")); + fprintf(fp, "%s", _("Issued By .: ")); parse_and_print_user_id(fp, s); putc('\n', fp); } @@ -3520,7 +3520,7 @@ static void print_key_info(gpgme_key_t key, FILE *fp) fprintf(fp, _("Key Type ..: %s, %lu bit %s\n"), "PGP", aval, s); /* L10N: DOTFILL */ - fprintf(fp, _("Key Usage .: ")); + fprintf(fp, "%s", _("Key Usage .: ")); delim = ""; if (subkey->can_encrypt) diff --git a/pattern.c b/pattern.c index d6f2f78e7..45f6503a5 100644 --- a/pattern.c +++ b/pattern.c @@ -87,7 +87,7 @@ static bool eat_regexp(struct Pattern *pat, struct Buffer *s, struct Buffer *err } if (!*buf.data) { - snprintf(err->data, err->dsize, _("Empty expression")); + snprintf(err->data, err->dsize, "%s", _("Empty expression")); return false; } @@ -395,7 +395,7 @@ static bool eat_date(struct Pattern *pat, struct Buffer *s, struct Buffer *err) } if (!*buffer.data) { - snprintf(err->data, err->dsize, _("Empty expression")); + snprintf(err->data, err->dsize, "%s", _("Empty expression")); return false; } @@ -1258,7 +1258,7 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer { if (!*ps.dptr) { - snprintf(err->data, err->dsize, _("missing parameter")); + snprintf(err->data, err->dsize, "%s", _("missing parameter")); mutt_pattern_free(&curlist); return NULL; } diff --git a/pop.c b/pop.c index 5cf293213..118f29fd5 100644 --- a/pop.c +++ b/pop.c @@ -109,7 +109,7 @@ static int pop_read_header(struct PopData *pop_data, struct Header *h) pop_data->cmd_top = 0; mutt_debug(1, "pop_read_header: unset TOP capability\n"); - snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), + snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), "%s", _("Command TOP is not supported by server.")); } } @@ -282,7 +282,7 @@ static int pop_fetch_headers(struct Context *ctx) pop_data->cmd_uidl = 0; mutt_debug(1, "pop_fetch_headers: unset UIDL capability\n"); - snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), + snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), "%s", _("Command UIDL is not supported by server.")); } } diff --git a/pop_auth.c b/pop_auth.c index f49f06313..0f9f1d302 100644 --- a/pop_auth.c +++ b/pop_auth.c @@ -275,7 +275,7 @@ static pop_auth_res_t pop_auth_user(struct PopData *pop_data, const char *method pop_data->cmd_user = 0; mutt_debug(1, "pop_auth_user: unset USER capability\n"); - snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), + snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), "%s", _("Command USER is not supported by server.")); } } -- 2.40.0