[patch] Two higher-level checks for invalid KProcess initialization

David Faure faure at kde.org
Thu Dec 6 23:30:04 GMT 2007


On Thursday 06 December 2007, Oswald Buddenhagen wrote:
> > 2. warning and failure is signalled within krun's runTempService() function 
> > when no args are extracted for the process.
> >
> > --- krun.cpp    (revision 745716)
> > +++ krun.cpp    (working copy)
> > @@ -634,6 +634,11 @@
> > +
> > +  if (args.isEmpty()) {
> > +      kWarning(7010) << "runTempService: KProcess no args!";
> > +      return false;
> > +  }
> >    kDebug(7010) << "runTempService: KProcess args=" << args;
> >
> i tend to using a q_assert here as well. 

This would launch a KProcess with no args in release mode. If that's fine, then ok.
I guess KRun's KProcessRunner shows an error message when doing that?

> other places dealing with 
> bogus .desktop files seem to do so as well.
> the alternative would be a proper messagebox.

How can this happen? Empty Exec field or invalid syntax, from what I can see?
I guess we can show a messagebox in either case, what matters most is to see
the name of the broken desktop file... Want to test this?

--- kio/krun.cpp        (revision 745320)
+++ kio/krun.cpp        (working copy)
@@ -634,6 +634,10 @@ static bool runTempService( const KServi
   {
       args = KRun::processDesktopExec(_service, _urls, tempFiles, suggestedFileName );
   }
+  if (args.isEmpty()) {
+      KMessageBox::sorry(window, i18n("Error processing Exec field in %1", _service.entryPath()) );
+      return false;
+  }
   kDebug(7010) << "runTempService: KProcess args=" << args;

   KProcess * proc = new KProcess;

Note that I wouldn't show a messagebox from processDesktopExec itself because that's
supposed to be a low-level non-gui method (e.g. it's also used by klauncher).

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list