]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Avoid passing NULL to argv_printf_cat() in temp_file error case.
authorGert Doering <gert@greenie.muc.de>
Tue, 13 Oct 2020 20:47:58 +0000 (22:47 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 15 Oct 2020 13:36:49 +0000 (15:36 +0200)
commit20965a18e52e60966ed754e6171e08ebe67432d6
treed269a9b5b827b3ea0c7e8adce461dd143ccd2faf
parent09aad8b4e1df91b7b6ed5163390eae3730b17d32
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>
(cherry picked from commit bbcada8abb410d077f7bc13b8157198b4bf6a3d1)
src/openvpn/ssl_verify.c