]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MINOR: ssl: remove one call to sprintf()
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Apr 2014 16:05:41 +0000 (18:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Apr 2014 16:05:41 +0000 (18:05 +0200)
Lukas reported another OpenBSD complaint about this use of sprintf() that
I missed :

src/ssl_sock.o(.text+0x2a79): In function `bind_parse_crt':
src/ssl_sock.c:3015: warning: sprintf() is often misused, please use snprintf()

This one was even easier to handle. Note that some of these calls could
be simplified by checking the snprintf output size instead of doing the
preliminary size computation.

src/ssl_sock.c

index f7c50c56845a3fe42ea56cafaa3c0ed700e4cffd..525c7b557ac80ccf7bee8483ffd1636c6c98f173 100644 (file)
@@ -3104,6 +3104,7 @@ static int bind_parse_ciphers(char **args, int cur_arg, struct proxy *px, struct
 static int bind_parse_crt(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
        char path[MAXPATHLEN];
+
        if (!*args[cur_arg + 1]) {
                memprintf(err, "'%s' : missing certificate location", args[cur_arg]);
                return ERR_ALERT | ERR_FATAL;
@@ -3114,7 +3115,7 @@ static int bind_parse_crt(char **args, int cur_arg, struct proxy *px, struct bin
                        memprintf(err, "'%s' : path too long", args[cur_arg]);
                        return ERR_ALERT | ERR_FATAL;
                }
-               sprintf(path, "%s/%s",  global.crt_base, args[cur_arg + 1]);
+               snprintf(path, sizeof(path), "%s/%s",  global.crt_base, args[cur_arg + 1]);
                if (ssl_sock_load_cert(path, conf, px, err) > 0)
                        return ERR_ALERT | ERR_FATAL;