mirror of
https://github.com/OpenVPN/openvpn.git
synced 2026-05-28 04:03:29 -04:00
Avoid passing NULL to argv_printf_cat() in temp_file error case.
To pass username + password to verify_user_pass_script(), OpenVPN
can either put both into environment, or create a temp file, and
pass that file name to the "user-pass-verify" script. The file
name is initialized as "", so if no file is desired, it's well
defined - but if the file can not be created, the pointer is NULL
afterwards.
Change the sequence of events, setting up the argv before the
"if (file)" conditional, and add the file name only inside that
clause, if creating the temp file succeeded.
commit a4eeef17b2 did not create the problem, but modified the
code enough so that the static analyzer in gcc 9.2.0 *now* noticed
and issued a warning.
ssl_verify.c:1132:5: warning: '%s' directive argument is null
1132 | argv_printf_cat(&argv, "%s", tmp_file);
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20201013204758.2472-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21204.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
a4eeef17b2
commit
bbcada8abb
1 changed files with 5 additions and 4 deletions
|
|
@ -1098,6 +1098,9 @@ verify_user_pass_script(struct tls_session *session, struct tls_multi *multi,
|
|||
/* Set environmental variables prior to calling script */
|
||||
setenv_str(session->opt->es, "script_type", "user-pass-verify");
|
||||
|
||||
/* format command line */
|
||||
argv_parse_cmd(&argv, session->opt->auth_user_pass_verify_script);
|
||||
|
||||
if (session->opt->auth_user_pass_verify_script_via_file)
|
||||
{
|
||||
struct status_output *so;
|
||||
|
|
@ -1115,6 +1118,8 @@ verify_user_pass_script(struct tls_session *session, struct tls_multi *multi,
|
|||
tmp_file);
|
||||
goto done;
|
||||
}
|
||||
/* pass temp file name to script */
|
||||
argv_printf_cat(&argv, "%s", tmp_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1127,10 +1132,6 @@ verify_user_pass_script(struct tls_session *session, struct tls_multi *multi,
|
|||
setenv_str(session->opt->es, "password", up->password);
|
||||
}
|
||||
|
||||
/* format command line */
|
||||
argv_parse_cmd(&argv, session->opt->auth_user_pass_verify_script);
|
||||
argv_printf_cat(&argv, "%s", tmp_file);
|
||||
|
||||
/* call command */
|
||||
ret = openvpn_run_script(&argv, session->opt->es, 0,
|
||||
"--auth-user-pass-verify");
|
||||
|
|
|
|||
Loading…
Reference in a new issue