comparison src/protocols/zephyr/zephyr.c @ 13453:efd3f93a220f

[gaim-migrate @ 15828] Fix CIDs 33, 34 & 35 (NULL dereferencing), 60 (fd leak) and 61 (memleak) committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 07 Mar 2006 14:43:00 +0000
parents 263c2db78f77
children 840607fdc801
comparison
equal deleted inserted replaced
13452:fd606401a8d2 13453:efd3f93a220f
252 */ 252 */
253 253
254 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2) 254 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2)
255 { 255 {
256 256
257 if (!zt2) 257 if (!zt2) {
258 gaim_debug_error("zephyr","zt2 doesn't exist\n"); 258 gaim_debug_error("zephyr","zt2 doesn't exist\n");
259 if (!zt1) 259 return FALSE;
260 }
261 if (!zt1) {
260 gaim_debug_error("zephyr","zt1 doesn't exist\n"); 262 gaim_debug_error("zephyr","zt1 doesn't exist\n");
261 if (!(zt1->class)) 263 return FALSE;
264 }
265 if (!(zt1->class)) {
262 gaim_debug_error("zephyr","zt1c doesn't exist\n"); 266 gaim_debug_error("zephyr","zt1c doesn't exist\n");
263 if (!(zt1->instance)) 267 return FALSE;
268 }
269 if (!(zt1->instance)) {
264 gaim_debug_error("zephyr","zt1i doesn't exist\n"); 270 gaim_debug_error("zephyr","zt1i doesn't exist\n");
265 if (!(zt1->recipient)) 271 return FALSE;
272 }
273 if (!(zt1->recipient)) {
266 gaim_debug_error("zephyr","zt1r doesn't exist\n"); 274 gaim_debug_error("zephyr","zt1r doesn't exist\n");
267 if (!(zt2->class)) 275 return FALSE;
276 }
277 if (!(zt2->class)) {
268 gaim_debug_error("zephyr","zt2c doesn't exist\n"); 278 gaim_debug_error("zephyr","zt2c doesn't exist\n");
269 if (!(zt2->recipient)) 279 return FALSE;
280 }
281 if (!(zt2->recipient)) {
270 gaim_debug_error("zephyr","zt2r doesn't exist\n"); 282 gaim_debug_error("zephyr","zt2r doesn't exist\n");
271 if (!(zt2->instance)) 283 return FALSE;
284 }
285 if (!(zt2->instance)) {
272 gaim_debug_error("zephyr","zt2i doesn't exist\n"); 286 gaim_debug_error("zephyr","zt2i doesn't exist\n");
273 287 return FALSE;
288 }
274 289
275 if (g_ascii_strcasecmp(zt2->class, zt1->class)) { 290 if (g_ascii_strcasecmp(zt2->class, zt1->class)) {
276 return FALSE; 291 return FALSE;
277 } 292 }
278 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) { 293 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) {
730 gaim_notify_userinfo(gc, b ? b->name : user, 745 gaim_notify_userinfo(gc, b ? b->name : user,
731 str->str, NULL, NULL); 746 str->str, NULL, NULL);
732 g_string_free(str, TRUE); 747 g_string_free(str, TRUE);
733 } else { 748 } else {
734 if (nlocs>0) 749 if (nlocs>0)
735 gaim_prpl_got_user_status(gc->account,b->name,"available",NULL); 750 gaim_prpl_got_user_status(gc->account, b ? b->name : user, "available", NULL);
736 else 751 else
737 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); 752 gaim_prpl_got_user_status(gc->account, b ? b->name : user, "offline", NULL);
738 } 753 }
739 754
740 g_free(user); 755 g_free(user);
741 } 756 }
742 } else { 757 } else {
915 } 930 }
916 } 931 }
917 932
918 static parse_tree *find_node(parse_tree* ptree,gchar* key) 933 static parse_tree *find_node(parse_tree* ptree,gchar* key)
919 { 934 {
920 gchar* tc = tree_child(ptree,0)->contents; 935 gchar* tc;
921 936
922 if (!ptree || ! key) 937 if (!ptree || ! key)
923 return &null_parse_tree; 938 return &null_parse_tree;
939
940 tc = tree_child(ptree,0)->contents;
924 941
925 if (ptree->num_children > 0 && tc && !strcasecmp(tc, key)) { 942 if (ptree->num_children > 0 && tc && !strcasecmp(tc, key)) {
926 return ptree; 943 return ptree;
927 } else { 944 } else {
928 parse_tree *result = &null_parse_tree; 945 parse_tree *result = &null_parse_tree;
1146 gaim_notify_userinfo(gc, b ? b->name : user, 1163 gaim_notify_userinfo(gc, b ? b->name : user,
1147 str->str, NULL, NULL); 1164 str->str, NULL, NULL);
1148 g_string_free(str, TRUE); 1165 g_string_free(str, TRUE);
1149 } else { 1166 } else {
1150 if (nlocs>0) 1167 if (nlocs>0)
1151 gaim_prpl_got_user_status(gc->account,b->name,"available",NULL); 1168 gaim_prpl_got_user_status(gc->account, b ? b->name : user, "available", NULL);
1152 else 1169 else
1153 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); 1170 gaim_prpl_got_user_status(gc->account, b ? b->name : user, "offline", NULL);
1154 } 1171 }
1155 } 1172 }
1156 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { 1173 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) {
1157 } 1174 }
1158 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { 1175 else if (!g_ascii_strncasecmp(spewtype,"start",5)) {
1457 g_free(recip); 1474 g_free(recip);
1458 } 1475 }
1459 g_strfreev(triple); 1476 g_strfreev(triple);
1460 } 1477 }
1461 } 1478 }
1479 fclose(f);
1462 } 1480 }
1463 } 1481 }
1464 1482
1465 static void process_anyone(GaimConnection *gc) 1483 static void process_anyone(GaimConnection *gc)
1466 { 1484 {
1666 while (ptr < bufcur && (*ptr !='(')) { 1684 while (ptr < bufcur && (*ptr !='(')) {
1667 ptr++; 1685 ptr++;
1668 } 1686 }
1669 if (ptr >=bufcur) { 1687 if (ptr >=bufcur) {
1670 gaim_connection_error(gc,"invalid output by tzc (or bad parsing code)"); 1688 gaim_connection_error(gc,"invalid output by tzc (or bad parsing code)");
1689 free(buf);
1671 return; 1690 return;
1672 } 1691 }
1673 1692
1674 while(ptr < bufcur) { 1693 while(ptr < bufcur) {
1675 if (*ptr == '(') { 1694 if (*ptr == '(') {
1756 /* This shouldn't be happening */ 1775 /* This shouldn't be happening */
1757 break; 1776 break;
1758 } 1777 }
1759 if (parenlevel==0) 1778 if (parenlevel==0)
1760 break; 1779 break;
1761 } /* while (ptr < bufcur) { */ 1780 } /* while (ptr < bufcur) */
1762 gaim_debug_info("zephyr", "tzc startup done\n"); 1781 gaim_debug_info("zephyr", "tzc startup done\n");
1782 free(buf);
1763 } 1783 }
1764 } 1784 }
1765 else if ( use_zeph02(zephyr)) { 1785 else if ( use_zeph02(zephyr)) {
1766 gchar* realm; 1786 gchar* realm;
1767 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); 1787 z_call_s(ZInitialize(), "Couldn't initialize zephyr");