changeset 1562:248da27faff3

Fix segfault when using /say_to with a bad syntax (reported by ISBear)
author Mikael Berthe <mikael@lilotux.net>
date Fri, 16 Jan 2009 22:26:51 +0100
parents 2e86c1cc4eb1
children 4b6cfaa6898b
files mcabber/src/commands.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/commands.c	Thu Oct 30 19:47:11 2008 +0100
+++ b/mcabber/src/commands.c	Fri Jan 16 22:26:51 2009 +0100
@@ -1459,7 +1459,7 @@
   }
 
   // Check for an option parameter
-  while (TRUE) {
+  while (*paramlst) {
     if (!strcmp(*paramlst, "-q")) {
       char **oldparamlst = paramlst;
       paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, message
@@ -1469,6 +1469,10 @@
       char **oldparamlst = paramlst;
       paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid
       free_arg_lst(oldparamlst);
+      if (!*paramlst) {
+        scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
+        return;
+      }
       file = g_strdup(*paramlst);
       // One more parameter shift...
       oldparamlst = paramlst;
@@ -1478,6 +1482,11 @@
       break;
   }
 
+  if (!*paramlst) {
+    scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
+    return;
+  }
+
   fjid = *paramlst;
   msg = *(paramlst+1);