]> git.ipfire.org Git - thirdparty/strongswan.git/blobdiff - src/scepclient/scepclient.c
scepclient: Don't use a block-scope buffer for the default DN
[thirdparty/strongswan.git] / src / scepclient / scepclient.c
index 853490f61cd1cf253640da604e0fb36a8e229118..754393455cf4d1699388891404af8b0001bd5ab6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2012 Tobias Brunner
  * Copyright (C) 2005 Jan Hutter, Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -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 <distinguished name> option");
                        }
-                       distinguishedName = buf;
+                       distinguishedName = default_distinguished_name;
                }
 
                DBG2(DBG_APP, "dn: '%s'", distinguishedName);