Skip to content

Commit 631abb6

Browse files
committed
scepclient: Don't use a block-scope buffer for the default DN
The correct behavior will depend on the compiler. Fixes #2843.
1 parent 686a1b9 commit 631abb6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/scepclient/scepclient.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ int main(int argc, char **argv)
455455

456456
/* distinguished name for requested certificate, ASCII format */
457457
char *distinguishedName = NULL;
458+
char default_distinguished_name[BUF_LEN];
458459

459460
/* challenge password */
460461
char challenge_password_buffer[MAX_PASSWORD_LENGTH];
@@ -1105,16 +1106,16 @@ int main(int argc, char **argv)
11051106
{
11061107
if (distinguishedName == NULL)
11071108
{
1108-
char buf[BUF_LEN];
1109-
int n = sprintf(buf, DEFAULT_DN);
1109+
int n = sprintf(default_distinguished_name, DEFAULT_DN);
11101110

11111111
/* set the common name to the hostname */
1112-
if (gethostname(buf + n, BUF_LEN - n) || strlen(buf) == n)
1112+
if (gethostname(default_distinguished_name + n, BUF_LEN - n) ||
1113+
strlen(default_distinguished_name) == n)
11131114
{
11141115
exit_scepclient("no hostname defined, use "
11151116
"--dn <distinguished name> option");
11161117
}
1117-
distinguishedName = buf;
1118+
distinguishedName = default_distinguished_name;
11181119
}
11191120

11201121
DBG2(DBG_APP, "dn: '%s'", distinguishedName);

0 commit comments

Comments
 (0)