summaryrefslogtreecommitdiff
path: root/bylabel.c
diff options
context:
space:
mode:
authorPetr Písař <ppisar@redhat.com>2018-02-05 10:31:47 +0100
committerJan Kara <jack@suse.cz>2018-02-05 16:44:12 +0100
commit338a07c9de2f5a86c7e030bde7fc2f3d9583c4dc (patch)
treef99dec52e1c9c963ada2711585c1321f3392f876 /bylabel.c
parentabbb2d17a3478e64173334ddb27f3d0a0f0372f9 (diff)
warnquota: Check snprintf() for overflows
GCC 8 with GNU libc 2.27 prerelease warns: gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -fPIC -I/usr/include/tirpc -c -o warnquota.o warnquota.c warnquota.c: In function ‘lookup_user’: warnquota.c:415:29: warning: ‘%s’ directive output may be truncated writing up to 2047 bytes into a region of size 255 [-Wformat-truncation=] snprintf(searchbuf, 256, "(%s=%s)", config->ldap_search_attr, user); ^~ warnquota.c:415:2: note: ‘snprintf’ output 4 or more bytes (assuming 2051) into a destination of size 256 snprintf(searchbuf, 256, "(%s=%s)", config->ldap_search_attr, user); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warnquota.c: In function ‘warn_quota’: warnquota.c:896:51: warning: ‘%s’ directive output may be truncated writing up to 2047 bytes into a region of size 2041 [-Wformat-truncation=] snprintf(config->ldap_uri, CNF_BUFFER, "ldap://%s:%d", config->ldap_host, config->ldap_port); ^~ ~~~~~~~~~~~~~~~~~ warnquota.c:896:4: note: ‘snprintf’ output between 10 and 2067 bytes into a destination of size 2048 snprintf(config->ldap_uri, CNF_BUFFER, "ldap://%s:%d", config->ldap_host, config->ldap_port); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is patch fixes it by catching the cases when snprintf() truncates and reporting an error. Perfect fix would fall back into dynamically allocated buffers but I think that would make these corner case too complicated provided nobody had yet complained about them. Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'bylabel.c')
0 files changed, 0 insertions, 0 deletions