[PATCH] MySQL Administrator segfaults on executing crontab

Sven Wegener <[email protected]>
Newsgroups gmane.comp.db.mysql.mycc
Message-ID <[email protected]>
Hi all!

MySQL Administrator has a bug which makes it to segfault when no cron
daemon is installed, or the user executing mysql-administrator has not
sufficient rights to execute crontab.

The problematic code is in mysql-gui-common/source/linux/MCrontab.cc in
line 225:

222  if (!g_spawn_command_line_sync(cmdline, &stdout_text, &stderr_text, &exit_status,
223                                 &error) || exit_status != 0)
224  {
225    if (!strstr(stderr_text, "no crontab"))
226    {
227      got_error= true;

We execute crontab via g_spawn_command_line_sync() and if it fails we
check stderr_text for "no crontab" with the strstr function. In case we
can't execute crontab, because no cron daemon is installed, or the user
has not sufficient rights to execute crontab, stderr_text will be NULL
and strstr produces a segfault.

Please find attached a patch which makes mysql-administrator to
correctly check for errors.

Cheers,
Sven

-- 
Sven Wegener
Gentoo Linux Developer
http://www.gentoo.org/
1.0.19-crontab.patch (text/plain, 688 B)
diff -Nur mysql-administrator-1.0.19.orig/mysql-gui-common/source/linux/MCrontab.cc mysql-administrator-1.0.19/mysql-gui-common/source/linux/MCrontab.cc
--- mysql-administrator-1.0.19.orig/mysql-gui-common/source/linux/MCrontab.cc	2005-01-11 20:02:31.429772354 +0100
+++ mysql-administrator-1.0.19/mysql-gui-common/source/linux/MCrontab.cc	2005-01-11 20:03:31.148873681 +0100
@@ -222,7 +222,7 @@
   if (!g_spawn_command_line_sync(cmdline, &stdout_text, &stderr_text, &exit_status,
                                  &error) || exit_status != 0)
   {
-    if (!strstr(stderr_text, "no crontab"))
+    if (!stderr_text || !strstr(stderr_text, "no crontab"))
     {
       got_error= true;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFB6DrP04iMKjbTpdgRAup/AJ9isTKQlhcKfjMKtXwaOAIzTZsEeACgh1VB
l28MzWoMdJm1fD8neuTk0sU=
=IMSg
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.