comparison mcabber/src/commands.c @ 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 4b4b3948420c
children ece4f26bf9ff
comparison
equal deleted inserted replaced
1561:2e86c1cc4eb1 1562:248da27faff3
1457 free_arg_lst(paramlst); 1457 free_arg_lst(paramlst);
1458 return; 1458 return;
1459 } 1459 }
1460 1460
1461 // Check for an option parameter 1461 // Check for an option parameter
1462 while (TRUE) { 1462 while (*paramlst) {
1463 if (!strcmp(*paramlst, "-q")) { 1463 if (!strcmp(*paramlst, "-q")) {
1464 char **oldparamlst = paramlst; 1464 char **oldparamlst = paramlst;
1465 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, message 1465 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, message
1466 free_arg_lst(oldparamlst); 1466 free_arg_lst(oldparamlst);
1467 quiet = TRUE; 1467 quiet = TRUE;
1468 } else if (!strcmp(*paramlst, "-f")) { 1468 } else if (!strcmp(*paramlst, "-f")) {
1469 char **oldparamlst = paramlst; 1469 char **oldparamlst = paramlst;
1470 paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid 1470 paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid
1471 free_arg_lst(oldparamlst); 1471 free_arg_lst(oldparamlst);
1472 if (!*paramlst) {
1473 scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
1474 return;
1475 }
1472 file = g_strdup(*paramlst); 1476 file = g_strdup(*paramlst);
1473 // One more parameter shift... 1477 // One more parameter shift...
1474 oldparamlst = paramlst; 1478 oldparamlst = paramlst;
1475 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, nothing 1479 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, nothing
1476 free_arg_lst(oldparamlst); 1480 free_arg_lst(oldparamlst);
1477 } else 1481 } else
1478 break; 1482 break;
1483 }
1484
1485 if (!*paramlst) {
1486 scr_LogPrint(LPRINT_NORMAL, "Wrong usage.");
1487 return;
1479 } 1488 }
1480 1489
1481 fjid = *paramlst; 1490 fjid = *paramlst;
1482 msg = *(paramlst+1); 1491 msg = *(paramlst+1);
1483 1492