diff options
author | Petr Písař <ppisar@redhat.com> | 2019-11-05 14:20:46 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2019-11-05 16:12:59 +0100 |
commit | 9a001cc6eb211758015d85cecc0464c94c82bbb5 (patch) | |
tree | 27cb788f38b23bb59293f95efb19bdbc782dea63 | |
parent | 603bd8e61c299fdc66776f4f4a76d5397981a76c (diff) | |
download | linuxquota-9a001cc6eb211758015d85cecc0464c94c82bbb5.tar.gz |
warnquota: Initialize all members of a configparams structure
Running warnquota under valgrind reported many "Conditional jump or
move depends on uninitialised value" mistakes because readconfigfile()
did not initizalize ldap_bindpw member if some of the configuration
options were missing from the configuration file.
This patch simply initializes all bytes of the configparams structure
to 0 instead of settting each of the members explicitly.
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | warnquota.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/warnquota.c b/warnquota.c index f6b42d5..2882fee 100644 --- a/warnquota.c +++ b/warnquota.c @@ -759,13 +759,13 @@ static int readconfigfile(const char *filename, struct configparams *config) char *locale; /* set default values */ + memset(config, 0, sizeof(*config)); sstrncpy(config->mail_cmd, MAIL_CMD, CNF_BUFFER); sstrncpy(config->from, FROM, CNF_BUFFER); sstrncpy(config->subject, SUBJECT, CNF_BUFFER); sstrncpy(config->cc_to, CC_TO, CNF_BUFFER); sstrncpy(config->support, SUPPORT, CNF_BUFFER); sstrncpy(config->phone, PHONE, CNF_BUFFER); - (config->charset)[0] = '\0'; setlocale(LC_ALL, NULL); locale = setlocale(LC_MESSAGES, NULL); #ifdef HAVE_NL_LANGINFO @@ -775,17 +775,11 @@ static int readconfigfile(const char *filename, struct configparams *config) } #endif maildev[0] = 0; - config->user_signature = config->user_message = config->group_signature = config->group_message = NULL; config->cc_before = -1; #ifdef USE_LDAP_MAIL_LOOKUP - config->use_ldap_mail = 0; - config->ldap_starttls = 0; config->ldap_tls = LDAP_OPT_X_TLS_NEVER; config->ldap_vers = LDAP_VERSION3; - config->ldap_port = config->ldap_is_setup = 0; - config->ldap_host[0] = 0; - config->ldap_uri[0] = 0; #endif if (!(fp = fopen(filename, "r"))) { |