From: Tobias Brunner Date: Fri, 30 Nov 2018 09:28:50 +0000 (+0100) Subject: scepclient: Don't use a block-scope buffer for the default DN X-Git-Tag: 5.7.2dr4~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=631abb68109d378a3633a9172200b936a1cae621;p=thirdparty%2Fstrongswan.git scepclient: Don't use a block-scope buffer for the default DN The correct behavior will depend on the compiler. Fixes #2843. --- diff --git a/src/scepclient/scepclient.c b/src/scepclient/scepclient.c index 83079f3d83..754393455c 100644 --- a/src/scepclient/scepclient.c +++ b/src/scepclient/scepclient.c @@ -455,6 +455,7 @@ int main(int argc, char **argv) /* distinguished name for requested certificate, ASCII format */ char *distinguishedName = NULL; + char default_distinguished_name[BUF_LEN]; /* challenge password */ char challenge_password_buffer[MAX_PASSWORD_LENGTH]; @@ -1105,16 +1106,16 @@ int main(int argc, char **argv) { if (distinguishedName == NULL) { - char buf[BUF_LEN]; - int n = sprintf(buf, DEFAULT_DN); + int n = sprintf(default_distinguished_name, DEFAULT_DN); /* set the common name to the hostname */ - if (gethostname(buf + n, BUF_LEN - n) || strlen(buf) == n) + if (gethostname(default_distinguished_name + n, BUF_LEN - n) || + strlen(default_distinguished_name) == n) { exit_scepclient("no hostname defined, use " "--dn option"); } - distinguishedName = buf; + distinguishedName = default_distinguished_name; } DBG2(DBG_APP, "dn: '%s'", distinguishedName);