Index: kdebase/kcontrol/thememgr/theme.cpp
diff -u kdebase/kcontrol/thememgr/theme.cpp:1.65.2.1 kdebase/kcontrol/thememgr/theme.cpp:1.65.2.3
--- kdebase/kcontrol/thememgr/theme.cpp:1.65.2.1        Wed Oct  3 19:28:45 2001
+++ kdebase/kcontrol/thememgr/theme.cpp Fri Dec  6 23:52:50 2002
@@ -53,6 +53,8 @@
#include <kicontheme.h>
#include <kipc.h>
#include <kdebug.h>
+#include <kprocess.h>
+
#include "theme.h"

#include <kio/netaccess.h>
@@ -90,7 +92,7 @@
Theme::~Theme()
{
  saveSettings();
-  if (mMappings) delete mMappings;
+  delete mMappings;
}


@@ -186,9 +188,12 @@
  int rc;

  // cleanup work directory
-  cmd = QString::fromLatin1( "rm -rf %1*" ).arg( workDir() );
-  rc = system(cmd.local8Bit());
-  if (rc) kdWarning() << "Error during cleanup of work directory: rc=" << rc << " " << cmd << endl;
+  if (!workDir().isEmpty()) {
+    KProcess p;
+    p << "/bin/rm" << "-rf" << workDir();
+    if(!p.start(KProcess::Block))
+      kdWarning() << "Error during cleanup of work directory: rc=" << rc << " " << cmd << endl;
+  }
}

void Theme::findThemerc(const QString &path, const QStringList &list)
@@ -238,11 +243,9 @@
    if (i >= 0) str = workDir() + aPath.mid(i);
    else str = workDir();

-    cmd = QString("cp -r \"%1\" \"%2\"").arg(aPath).arg(str);
-    kdDebug() << cmd << endl;
-    rc = system(QFile::encodeName(cmd).data());
-    if (rc)
-    {
+    KProcess p;
+    p << "/bin/cp" << "-r" << aPath << str;
+    if(!p.start(KProcess::Block)) {
      error = i18n("Theme contents could not be copied from\n%1\ninto\n%2")
               .arg(aPath).arg(str);
      return false;
@@ -251,8 +254,7 @@
  else if (aPath.right(4) == ".zip")
  {
    // The theme given is a zip archive. Unpack the archive.
-    cmd = QString("cd \"%1\"; unzip -qq \"%2\"")
-             .arg(workDir()).arg(aPath);
+    cmd = QString::fromLatin1("cd ") + KShellProcess::quote(workDir()) + "; unzip -qq " + KShellProcess::quote(aPath);
    kdDebug() << cmd << endl;
    rc = system(QFile::encodeName(cmd).data());
    if (rc)
@@ -265,9 +267,7 @@
  else
  {
    // The theme given is a tar package. Unpack theme package.
-    cmd = QString("cd \"%1\"; gzip -c -d \"%2\" | tar xf -")
-             .arg(workDir()).arg(aPath);
-    kdDebug() << cmd << endl;
+    cmd = QString::fromLatin1("cd ") + KShellProcess::quote(workDir()) + "; gzip -c -d " + KShellProcess::quote(aPath) + " | tar xf -";
    rc = system(QFile::encodeName(cmd).data());
    if (rc)
    {
@@ -366,9 +366,7 @@
    path += defaultExtension();
  }

-  QString cmd = QString("cd \"%1\";tar cf - *|gzip -c >\"%2\"").
-               arg(workDir()).arg(path);
-
+  QString cmd = QString::fromLatin1("cd ") + KShellProcess::quote(workDir()) + ";tar cf - *|gzip -c >" + KShellProcess::quote(path);
  kdDebug() << cmd << endl;
  int rc = system(QFile::encodeName(cmd).data());
  if (rc) kdDebug() << "Failed to save theme to " << aPath << " with command " << cmd << endl;
@@ -993,8 +991,8 @@
      appName = cmd.mid(7).stripWhiteSpace();
      str = i18n("Restart %1 to activate the new settings?").arg( appName );
      if (KMessageBox::questionYesNo(0, str) == KMessageBox::Yes) {
-          str.sprintf(mRestartCmd.local8Bit().data(), appName.local8Bit().data(),
-                      appName.local8Bit().data());
+          str.sprintf(mRestartCmd.local8Bit().data(), KShellProcess::quote(appName).local8Bit().data(),
+                      KShellProcess::quote(appName).local8Bit().data());
          system(str.local8Bit());
      }
    }
@@ -1014,11 +1012,7 @@
  if (!fi.exists()) return false;

  QFile::remove((fname + '~'));
-  cmd.sprintf("mv \"%s\" \"%s~\"", fname.local8Bit().data(),
-             fname.local8Bit().data());
-  rc = system(cmd.local8Bit());
-  if (rc) kdWarning() << "Cannot make backup copy of "
-          << fname << ": mv returned " << rc << endl;
+  rc = ::rename(fname.local8Bit().data(), QString(fname + "~").local8Bit().data());
  return (rc==0);
}

Index: kdebase/kcontrol/usbview/usbdevices.cpp
diff -u kdebase/kcontrol/usbview/usbdevices.cpp:1.3 kdebase/kcontrol/usbview/usbdevices.cpp:1.3.2.1
--- kdebase/kcontrol/usbview/usbdevices.cpp:1.3 Thu Jul  5 13:46:11 2001
+++ kdebase/kcontrol/usbview/usbdevices.cpp     Fri Dec  6 12:30:40 2002
@@ -73,9 +73,9 @@
    }
  else if (line.left(2) == "D:")
    {
-      char buffer[10];
+      char buffer[11];
      sscanf(line.local8Bit().data(),
-            "D:  Ver=%x.%x Cls=%x(%s) Sub=%x Prot=%x MxPS=%d #Cfgs=%d",
+            "D:  Ver=%x.%x Cls=%x(%10s) Sub=%x Prot=%x MxPS=%d #Cfgs=%d",
            &_verMajor, &_verMinor, &_class, buffer, &_sub, &_prot, &_maxPacketSize, &_configs);
      _className = buffer;
    }
Index: kdebase/kdm/backend/dm.c
diff -u kdebase/kdm/backend/dm.c:1.26.2.2 kdebase/kdm/backend/dm.c:1.26.2.4
--- kdebase/kdm/backend/dm.c:1.26.2.2   Wed Oct  3 12:47:11 2001
+++ kdebase/kdm/backend/dm.c    Fri Dec 13 12:11:19 2002
@@ -363,6 +363,11 @@
#define UT_LINESIZE 32
#endif

+#define __stringify(x) #x
+#define stringify(x) __stringify(x)
+
+#define UT_LINESIZE_S stringify(UT_LINESIZE)
+
struct utmps {
    struct utmps *next;
    struct display *d;
@@ -436,7 +441,7 @@
#else
                   if (ut->ut_type == LOGIN_PROCESS)
                   {
-                       Debug ("utmp entry for %s marked waiting\n", utp->line);
+                       Debug ("utmp entry for %." UT_LINESIZE_S "s marked waiting\n", utp->line);
                       utp->state = UtWait;
                   }
                   else if (ut->ut_type != USER_PROCESS)
@@ -445,7 +450,7 @@
#endif
                   {
                       utp->hadSess = 1;
-                       Debug ("utmp entry for %s marked active\n", utp->line);
+                       Debug ("utmp entry for %." UT_LINESIZE_S "s marked active\n", utp->line);
                       utp->state = UtActive;
                   }
                   if (utp->time < ut->ut_time)
@@ -460,7 +465,7 @@
           {
               utp->state = UtWait;
               utp->time = now;
-               Debug ("utmp entry for %s marked waiting\n", utp->line);
+               Debug ("utmp entry for %." UT_LINESIZE_S "s marked waiting\n", utp->line);
           }
#elif defined(sun)
       endutxent();
@@ -479,8 +484,8 @@
           if (remains <= 0)
           {
               struct display *d = utp->d;
-               Debug ("console login for %s at %s timed out\n",
-                      utp->d->name, utp->line);
+               Debug ("console login for %s at %." UT_LINESIZE_S "s timed out\n",
+                      d->name, utp->line);
               *utpp = utp->next;
               free (utp);
               ExitDisplay (d, TRUE, TRUE, TRUE);
Index: kdebase/kioslave/finger/kio_finger.cpp
diff -u kdebase/kioslave/finger/kio_finger.cpp:1.15 kdebase/kioslave/finger/kio_finger.cpp:1.15.2.1
--- kdebase/kioslave/finger/kio_finger.cpp:1.15 Fri May 11 22:59:50 2001
+++ kdebase/kioslave/finger/kio_finger.cpp      Fri Dec  6 03:35:07 2002
@@ -123,7 +123,7 @@

  //kdDebug() << "Refresh rate: " << refreshRate << endl;

-  myKProcess = new KShellProcess();
+  myKProcess = new KProcess();
  *myKProcess << *myPerlPath << *myFingerPerlScript
             << *myFingerPath << *myFingerCSSFile
             << refreshRate << myURL->host() << myURL->user() ;
Index: kdebase/kioslave/finger/kio_finger.h
diff -u kdebase/kioslave/finger/kio_finger.h:1.6 kdebase/kioslave/finger/kio_finger.h:1.6.4.1
--- kdebase/kioslave/finger/kio_finger.h:1.6    Thu Nov  2 19:48:09 2000
+++ kdebase/kioslave/finger/kio_finger.h        Fri Dec  6 03:35:07 2002
@@ -54,7 +54,7 @@
  QString              *myStdStream;


-  KShellProcess                *myKProcess;
+  KProcess             *myKProcess;

  void       getProgramPath();
  void       parseCommandLine(const KURL& url);
Index: kdebase/kioslave/finger/kio_finger.pl
diff -u kdebase/kioslave/finger/kio_finger.pl:1.7 kdebase/kioslave/finger/kio_finger.pl:1.7.2.1
--- kdebase/kioslave/finger/kio_finger.pl:1.7   Sun Jul 29 18:58:28 2001
+++ kdebase/kioslave/finger/kio_finger.pl       Fri Dec  6 03:35:07 2002
@@ -65,8 +65,9 @@

# Run finger command and save it into a buffer

-$buffer = `$FINGERCMD $USER\@$HOST`;
-@lines = split /^/m, $buffer;
+open(F, "-|") || exec $FINGERCMD, "$USER\@$HOST";
+@lines = <F>;
+close(F);

# Do highlighting using perl regular expressions on every line received.
# Order is important here.
Index: kdebase/kioslave/info/info.cc
diff -u kdebase/kioslave/info/info.cc:1.16 kdebase/kioslave/info/info.cc:1.16.4.1
--- kdebase/kioslave/info/info.cc:1.16  Sun Dec  3 22:01:55 2000
+++ kdebase/kioslave/info/info.cc       Fri Dec  6 17:53:42 2002
@@ -63,11 +63,21 @@
    if ( m_page.isEmpty() )
      m_page = "dir";

-    QString cmds("%1 %2 %3 %4 \"%5\" \"%6\"");
-    QCString cmd = cmds.arg(m_perl).arg(m_infoScript).arg(locate("data", "kio_info/kde-info2html.conf")).arg(KGlobal::dirs()->findResourceDir("icon", "hicolor/22x22/actions/up.png")).arg(m_page).arg(m_node).latin1();
-    //kdDebug( 7108 ) << "cmd: " << (const char *)cmd << endl;
+    QString cmd = KShellProcess::quote(m_perl);
+    cmd += " ";
+    cmd += KShellProcess::quote(m_infoScript);
+    cmd += " ";
+    cmd += KShellProcess::quote(locate("data", "kio_info/kde-info2html.conf"));
+    cmd += " ";
+    cmd += KShellProcess::quote(KGlobal::dirs()->findResourceDir("icon", "hicolor/22x22/actions/up.png"));
+    cmd += " ";
+    cmd += KShellProcess::quote(m_page);
+    cmd += " ";
+    cmd += KShellProcess::quote(m_node);

-    FILE *fd = popen( cmd.data(), "r" );
+    kdDebug( 7108 ) << "cmd: " << cmd << endl;
+
+    FILE *fd = popen( QFile::encodeName(cmd), "r" );

    char buffer[ 4090 ];
    QByteArray array;
Index: kdebase/klipper/klipperrc
diff -u kdebase/klipper/klipperrc:1.26.2.1 kdebase/klipper/klipperrc:1.26.2.2
--- kdebase/klipper/klipperrc:1.26.2.1  Sat Aug 25 22:34:26 2001
+++ kdebase/klipper/klipperrc   Sat Dec  7 03:07:40 2002
@@ -4,7 +4,7 @@
Regexp=^\\/.+\\.jpg$

[Action_0/Command_0]
-Commandline=kview "%s"
+Commandline=kview %s
Description=Launch K&View
Enabled=true

@@ -14,7 +14,7 @@
Regexp=^https?:\\/\\/

[Action_1/Command_0]
-Commandline=kfmclient exec '%s'
+Commandline=kfmclient exec %s
Description=Open with &Konqueror
Enabled=true

@@ -29,12 +29,12 @@
Enabled=true

[Action_1/Command_3]
-Commandline=kmail --body  '%s'
+Commandline=kmail --body  %s
Description=Send &URL
Enabled=true

[Action_1/Command_4]
-Commandline=kmail  --attach '%s'
+Commandline=kmail  --attach %s
Description=Send &Page
Enabled=true

@@ -49,7 +49,7 @@
Enabled=true

[Action_2/Command_1]
-Commandline=konsole -e mutt `echo "%s" | sed 's/mailto://g'`
+Commandline=konsole -e mutt `echo %s | sed 's/mailto://g'`
Description=Launch &mutt
Enabled=true

@@ -59,12 +59,12 @@
Regexp=^\\/.+\\.txt$

[Action_3/Command_0]
-Commandline=kedit "%s"
+Commandline=kedit %s
Description=Launch K&Edit
Enabled=true

[Action_3/Command_1]
-Commandline=kwrite "%s"
+Commandline=kwrite %s
Description=Launch K&Write
Enabled=true

@@ -74,12 +74,12 @@
Regexp=^file:.

[Action_4/Command_0]
-Commandline=kmail --body  '%s'
+Commandline=kmail --body  %s
Description=Send &URL
Enabled=true

[Action_4/Command_1]
-Commandline=kmail  --attach '%s'
+Commandline=kmail  --attach %s
Description=Send &File
Enabled=true

@@ -89,12 +89,12 @@
Regexp=^gopher:.

[Action_5/Command_0]
-Commandline=kmail --body  '%s'
+Commandline=kmail --body  %s
Description=Send &URL
Enabled=true

[Action_5/Command_1]
-Commandline=kmail  --attach '%s'
+Commandline=kmail  --attach %s
Description=Send &File
Enabled=true

@@ -104,7 +104,7 @@
Regexp=^ftp:\\/\\/

[Action_6/Command_0]
-Commandline=kfmclient exec '%s'
+Commandline=kfmclient exec %s
Description=Open with &Konqueror
Enabled=true

@@ -119,12 +119,12 @@
Enabled=true

[Action_6/Command_3]
-Commandline=kmail --body  '%s'
+Commandline=kmail --body  %s
Description=Send &URL
Enabled=true

[Action_6/Command_4]
-Commandline=kmail  --attach '%s'
+Commandline=kmail  --attach %s
Description=Send &File
Enabled=true

Index: kdebase/klipper/toplevel.cpp
diff -u kdebase/klipper/toplevel.cpp:1.59.2.2 kdebase/klipper/toplevel.cpp:1.59.2.3
--- kdebase/klipper/toplevel.cpp:1.59.2.2       Sat Oct 27 22:42:36 2001
+++ kdebase/klipper/toplevel.cpp        Sun Nov 11 15:36:16 2001
@@ -39,7 +39,7 @@
#define CONFIG_ITEM  60
#define EMPTY_ITEM   80

-#define MENU_ITEMS   7
+#define MENU_ITEMS   8
// the <clipboard empty> item
#define EMPTY (pQPMmenu->count() - MENU_ITEMS)

Index: kdebase/klipper/urlgrabber.cpp
diff -u kdebase/klipper/urlgrabber.cpp:1.23.2.2 kdebase/klipper/urlgrabber.cpp:1.23.2.3
--- kdebase/klipper/urlgrabber.cpp:1.23.2.2     Tue Oct 30 16:28:23 2001
+++ kdebase/klipper/urlgrabber.cpp      Sat Dec  7 03:07:40 2002
@@ -201,42 +201,39 @@
{
    if ( command->isEnabled ) {
        QString cmdLine = command->command;
+        QString escClipData = KShellProcess::quote(myClipData);

-        // escape $ to avoid it being expanded by the shell
-        QString escClipData = myClipData;
-        escClipData.replace( QRegExp( "\\$" ), "\\$" );
-
-        // replace "%s" with the clipboard contents
+        // replace "%s", '%s' and %s with the clipboard contents
+        // the quotes have to be replaced as well as they might
+        // be part of config files from older klipper versions
        // replace \%s to %s
-        int pos = 0;
-
+        int pos;
        while ( (pos = cmdLine.find("%s", pos)) >= 0 ) {
-            if ( pos > 0 && cmdLine.at( pos -1 ) == '\\' ) {
+            if ( pos > 0 && cmdLine.at( pos - 1 ) == '\\' ) {
                cmdLine.remove( pos -1, 1 ); // \%s -> %s
                pos++;
            }
+            else if (pos > 0 && (cmdLine[pos - 1] == '\'' || cmdLine[pos - 1] == '"') &&
+                     pos + 2 < cmdLine.length() && cmdLine[pos + 2] == cmdLine[pos - 1]) {
+                cmdLine.replace ( pos - 1, 4, escClipData );
+                pos += escClipData.length();
+            }
            else {
                cmdLine.replace( pos, 2, escClipData );
                pos += escClipData.length();
            }
        }

-        startProcess( cmdLine );
-    }
-}
-
-
-void URLGrabber::startProcess( const QString& cmdLine ) const
-{
-    kdDebug() << "now starting " << cmdLine << endl;
-    if ( cmdLine.isEmpty() )
-        return;
+        kdDebug() << "now starting " << cmdLine << endl;
+        if ( cmdLine.isEmpty() )
+            return;

-    KShellProcess proc;
-    proc << cmdLine.simplifyWhiteSpace().stripWhiteSpace();
+        KShellProcess proc;
+        proc << cmdLine.stripWhiteSpace();

-    if ( !proc.start(KProcess::DontCare, KProcess::NoCommunication ))
-        qWarning("Klipper: Couldn't start process!");
+        if ( !proc.start(KProcess::DontCare, KProcess::NoCommunication ))
+            qWarning("Klipper: Couldn't start process!");
+    }
}


Index: kdebase/klipper/urlgrabber.h
diff -u kdebase/klipper/urlgrabber.h:1.10 kdebase/klipper/urlgrabber.h:1.10.4.1
--- kdebase/klipper/urlgrabber.h:1.10   Tue Jan 30 22:46:15 2001
+++ kdebase/klipper/urlgrabber.h        Sat Dec  7 03:07:40 2002
@@ -63,7 +63,6 @@
private:
  const ActionList& matchingActions( const QString& );
  void execute( const struct ClipCommand *command ) const;
-  void startProcess( const QString& cmdLine ) const;
  void editData();
  bool isAvoidedWindow() const;
  void actionMenu( bool wm_class_check );
Index: kdebase/konsole/src/TEWidget.C
diff -u kdebase/konsole/src/TEWidget.C:1.76.2.5 kdebase/konsole/src/TEWidget.C:1.76.2.8
--- kdebase/konsole/src/TEWidget.C:1.76.2.5     Mon Oct  1 23:11:44 2001
+++ kdebase/konsole/src/TEWidget.C      Wed Feb 20 09:58:27 2002
@@ -1172,7 +1172,7 @@
          dropText += " ";
          bPopup = false; // more than one file, don't popup
        }
-        KURL url(p);
+        KURL url(QUriDrag::uriToUnicodeUri(p));
        QString tmp;
        if (url.isLocalFile()) {
          tmp = url.path(); // local URL : remove protocol
@@ -1181,7 +1181,8 @@
          tmp = url.url();
          bPopup = false; // a non-local file, don't popup
        }
-        KRun::shellQuote(tmp);
+        if (strlist.count()>1)
+          KRun::shellQuote(tmp);
        dropText += tmp;
      }

@@ -1212,6 +1213,7 @@
   switch (item)
   {
   case 0: // paste
+      KRun::shellQuote(dropText);
      currentSession->getEmulation()->sendString(dropText.local8Bit());
//    KWM::activate((Window)this->winId());
      break;
@@ -1227,7 +1229,7 @@
            dropText = url.directory( true, false ); // remove filename
         }
      }
-      dropText.replace(QRegExp(" "), "\\ "); // escape spaces
+      KRun::shellQuote(dropText);
      currentSession->getEmulation()->sendString(dropText.local8Bit());
      currentSession->getEmulation()->sendString("\n");
      //    KWM::activate((Window)this->winId());
Index: kdebase/kscreensaver/kxsconfig/kxsconfig.cpp
diff -u kdebase/kscreensaver/kxsconfig/kxsconfig.cpp:1.8 kdebase/kscreensaver/kxsconfig/kxsconfig.cpp:1.8.6.1
--- kdebase/kscreensaver/kxsconfig/kxsconfig.cpp:1.8    Wed Aug  2 01:20:45 2000
+++ kdebase/kscreensaver/kxsconfig/kxsconfig.cpp        Thu Feb 21 13:48:16 2002
@@ -256,7 +256,8 @@
  KApplication app;

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
+  if(args->count()==0)
+    exit(1);
  KXSConfigDialog *dialog = new KXSConfigDialog(args->arg(0));
  dialog->show();

Index: kdebase/ksysguard/ksysguardd/Linux/diskstat.c
diff -u kdebase/ksysguard/ksysguardd/Linux/diskstat.c:1.7 kdebase/ksysguard/ksysguardd/Linux/diskstat.c:1.7.2.1
--- kdebase/ksysguard/ksysguardd/Linux/diskstat.c:1.7   Mon Jun  4 16:45:05 2001
+++ kdebase/ksysguard/ksysguardd/Linux/diskstat.c       Fri Dec  6 11:44:57 2002
@@ -44,7 +44,7 @@

char *getMntPnt(const char *cmd)
{
-       static char device[1024];
+       static char device[1025];
       char *ptr;

       memset(device, 0, sizeof(device));
Index: kdebase/ksysguard/ksysguardd/Linux/logfile.c
diff -u kdebase/ksysguard/ksysguardd/Linux/logfile.c:1.6 kdebase/ksysguard/ksysguardd/Linux/logfile.c:1.6.2.1
--- kdebase/ksysguard/ksysguardd/Linux/logfile.c:1.6    Thu Jul 26 23:32:28 2001
+++ kdebase/ksysguard/ksysguardd/Linux/logfile.c        Fri Dec  6 11:50:04 2002
@@ -102,7 +102,7 @@

void registerLogFile(const char* cmd)
{
-       char name[256];
+       char name[257];
       FILE* file;
       LogFileEntry *entry;
       int i;
Index: kdebase/ksysguard/ksysguardd/Linux/stat.c
diff -u kdebase/ksysguard/ksysguardd/Linux/stat.c:1.18 kdebase/ksysguard/ksysguardd/Linux/stat.c:1.18.2.1
--- kdebase/ksysguard/ksysguardd/Linux/stat.c:1.18      Mon Jun  4 16:45:05 2001
+++ kdebase/ksysguard/ksysguardd/Linux/stat.c   Fri Dec  6 11:57:40 2002
@@ -963,10 +963,10 @@
printDiskIO(const char* cmd)
{
       int major, minor;
-       char name[16];
+       char name[17];
       DiskIOInfo* ptr;

-       sscanf(cmd, "disk/%d:%d/%s", &major, &minor, name);
+       sscanf(cmd, "disk/%d:%d/%16s", &major, &minor, name);

       if (Dirty)
               processStat();
@@ -1009,10 +1009,10 @@
printDiskIOInfo(const char* cmd)
{
       int major, minor;
-       char name[16];
+       char name[17];
       DiskIOInfo* ptr = DiskIO;

-       sscanf(cmd, "disk/%d:%d/%s", &major, &minor, name);
+       sscanf(cmd, "disk/%d:%d/%16s", &major, &minor, name);

       while (ptr && (ptr->major != major || ptr->minor != minor))
               ptr = ptr->next;