aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/passwordauth.pm
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-01-11 13:22:03 +0000
committerSimon McVittie <smcv@debian.org>2017-01-11 18:11:07 +0000
commitd157a97452ae0641f87996b6d0f21c9d222cef3d (patch)
treeef0032b1d5f83010b0f084557fc3690c9b46a7b9 /IkiWiki/Plugin/passwordauth.pm
parentb642cbef80d120df3c9f3146eb1e39dfbe395a2d (diff)
downloadikiwiki-d157a97452ae0641f87996b6d0f21c9d222cef3d.tar
ikiwiki-d157a97452ae0641f87996b6d0f21c9d222cef3d.tar.gz
CGI, attachment, passwordauth: harden against repeated parameters
These instances of code similar to OVE-20170111-0001 are not believed to be exploitable, because defined(), length(), setpassword(), userinfo_set() and the binary "." operator all have prototypes that force the relevant argument to be evaluated in scalar context. However, using a safer idiom makes mistakes less likely. (cherry picked from commit 69230a2220f673c66b5ab875bfc759b32a241c0d)
Diffstat (limited to 'IkiWiki/Plugin/passwordauth.pm')
-rw-r--r--IkiWiki/Plugin/passwordauth.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm
index 86f93d717..33b8efbed 100644
--- a/IkiWiki/Plugin/passwordauth.pm
+++ b/IkiWiki/Plugin/passwordauth.pm
@@ -333,10 +333,12 @@ sub formbuilder (@) {
}
elsif ($form->submitted eq 'Create Account') {
my $email = $form->field('email');
+ my $password = $form->field('password');
+
if (IkiWiki::userinfo_setall($user_name, {
'email' => $email,
'regdate' => time})) {
- setpassword($user_name, $form->field('password'));
+ setpassword($user_name, $password);
$form->field(name => "confirm_password", type => "hidden");
$form->field(name => "email", type => "hidden");
$form->text(gettext("Account creation successful. Now you can Login."));
@@ -395,8 +397,9 @@ sub formbuilder (@) {
elsif ($form->title eq "preferences") {
if ($form->submitted eq "Save Preferences" && $form->validate) {
my $user_name=$form->field('name');
- if (defined $form->field("password") && length $form->field("password")) {
- setpassword($user_name, scalar $form->field('password'));
+ my $password=$form->field('password');
+ if (defined $password && length $password) {
+ setpassword($user_name, $password);
}
}
}