Item12956: Unitialized variable crash after using back button to return to edit, and save.

pencil
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: FoswikiPrefs, FoswikiRequest, FoswikiUISave
Branches: trunk
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
Reproducable on trunk.foswiki.org

  • Edit a topic
  • Save
  • Use browser back button to return to edit
  • Change and save again
  • Confirm the Strike One suspicious change warning
  • Crash

 Use of uninitialized value $values[0] in join or string at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Prefs/Request.pm line 59.
 at /usr/local/lib/perl5/5.16/CGI/Carp.pm line 379.
   CGI::Carp::realdie("Use of uninitialized value \$values[0] in join or string at /u"...) called at /usr/local/lib/perl5/5.16/CGI/Carp.pm line 468
   CGI::Carp::die("Use of uninitialized value \$values[0] in join or string at /u"...) called at /usr/home/trunk.foswiki.org/core/lib/AssertOn.pm line 14
   Assert::__ANON__("Use of uninitialized value \$values[0] in join or string at /u"...) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Prefs/Request.pm line 59
   Foswiki::Prefs::Request::set(Foswiki::Request=HASH(0x802942e58), Foswiki::Meta=HASH(0x8042b9828)) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/Save.pm line 222
   Foswiki::UI::Save::buildNewTopic(Foswiki=HASH(0x802c599a8), Foswiki::Meta=HASH(0x8042b9828), "save") called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/Save.pm line 635
   Foswiki::UI::Save::save(Foswiki=HASH(0x802c599a8)) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 346
   Foswiki::UI::__ANON__() called at /usr/local/lib/perl5/site_perl/5.16/Error.pm line 421
   eval {...} called at /usr/local/lib/perl5/site_perl/5.16/Error.pm line 413
   Error::subs::try(CODE(0x8010915d0), HASH(0x802c59468)) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 467
   Foswiki::UI::_execute(Foswiki::Request=HASH(0x802942e58), CODE(0x8029a3750), "save", 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 299
   Foswiki::UI::handleRequest(Foswiki::Request=HASH(0x802942e58)) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Engine/CGI.pm line 89
   Foswiki::Engine::CGI::run(Foswiki::Engine::CGI=HASH(0x8018c2540)) called at /home/trunk.foswiki.org/core/bin/save line 29.

-- GeorgeClark - 02 Jul 2014

I think this needs an assist from you as well Crawford. The difference is that on a save, the empty params are set to '', and after the redirect they are undef. Below is a snippet of a Data::Dumper dump of the Foswiki::Request:

Save

                   'param' => {
                                'redirectto' => [
                                                  ''
                                                ],
                                'action_addform' => [
                                                      ''
                                                    ],
                                'action_save' => [
                                                   'Save'
                                                 ],
                                'Default+ALLOWTOPICVIEW' => [
                                                              'undefined'
                                                            ],
                                'nowysiwyg' => [
                                                 ''
                                               ],
                                'Set+ALLOWTOPICCHANGE' => [
                                                            'undefined'
                                                          ],
                                'action_checkpoint' => [
                                                         ''
                                                       ],
                                'Local+PERMSET_CHANGE' => [
                                                            'default'
                                                          ],
                                'Default+PERMSET_CHANGE' => [
                                                              'default'
                                                            ],
                                'Local+PERMSET_VIEW' => [
                                                          'everybody'
                                                        ],

Redirect

                   'param' => {
                                'redirectto' => [
                                                  undef
                                                ],
                                'action_addform' => [
                                                      undef
                                                    ],
                                'action_save' => [
                                                   'Save'
                                                 ],
                                'Default+ALLOWTOPICVIEW' => [
                                                              'undefined'
                                                            ],
                                'nowysiwyg' => [
                                                 undef
                                               ],
                                'Set+ALLOWTOPICCHANGE' => [
                                                            'undefined'
                                                          ],
                                'action_checkpoint' => [
                                                         undef
                                                       ],
                                'Local+PERMSET_CHANGE' => [
                                                            'default'
                                                          ],
                                'Default+PERMSET_CHANGE' => [
                                                              'default'
                                                            ],
                                'Local+PERMSET_VIEW' => [
                                                          'everybody'
                                                        ],
                                'Default+DENYTOPICCHANGE' => [
                                                               'undefined'
                                                             ],

The fix is pretty simple if I can just check for defined in Foswiki::Prefs::Request::set, but is this where the problem lies, or is the triggered when the redirect cache rebuilds the query?

-- GeorgeClark - 02 Jul 2014

This seems to be a fix.
diff --git a/core/lib/Foswiki/Request.pm b/core/lib/Foswiki/Request.pm
index 62bb2c3..a8e8210 100644
--- a/core/lib/Foswiki/Request.pm
+++ b/core/lib/Foswiki/Request.pm
@@ -625,6 +625,7 @@ sub load {
         last if /^=$/;
         my ( $key, $value ) =
           map { defined $_ ? Foswiki::urlDecode($_) : $_ } split /=/;
+        $value = '' unless defined $value;
         if ( exists $param{$key} ) {
             push @{ $param{$key} }, $value;
         }

-- GeorgeClark - 02 Jul 2014

Whoops - broke the unit tests. Reopening.

-- GeorgeClark - 05 Jul 2014
 

ItemTemplate edit

Summary Unitialized variable crash after using back button to return to edit, and save.
ReportedBy GeorgeClark
Codebase trunk
SVN Range
AppliesTo Engine
Component FoswikiPrefs, FoswikiRequest, FoswikiUISave
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:e3ea4304173f distro:0ba0ed919ced
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches trunk
trunkCheckins distro:e3ea4304173f distro:0ba0ed919ced
Release01x01Checkins
Topic revision: r9 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy