changeset 2281:cc462108c101

[gaim-migrate @ 2291] hopefully this should fix a couple things... committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 13 Sep 2001 23:42:44 +0000
parents 13d5d7e829c9
children 0dea5214d63f
files src/buddy.c src/protocols/toc/toc.c
diffstat 2 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy.c	Thu Sep 13 22:57:53 2001 +0000
+++ b/src/buddy.c	Thu Sep 13 23:42:44 2001 +0000
@@ -2991,12 +2991,11 @@
 					gc->permdeny = 1;
 			}
 		} while ((c = strtok(NULL, "\n")));
-#if 0
-		fprintf(stdout, "Sending message '%s'\n", buf);
-#endif
-
-		if (bud != NULL)
+
+		if (bud != NULL) {
 			serv_add_buddies(gc, bud);
+			g_list_free(bud);
+		}
 		serv_set_permit_deny(gc);
 	}
 
@@ -3025,11 +3024,11 @@
 		gc->permdeny = 1;
 
 	pos += g_snprintf(&s[pos], len - pos, "m %d\n", gc->permdeny);
-	while (grp) {
+	while (len > pos && grp) {
 		g = (struct group *)grp->data;
 		pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
 		mem = g->members;
-		while (mem) {
+		while (len > pos && mem) {
 			b = (struct buddy *)mem->data;
 			pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name,
 					  (show && strcmp(b->name, b->show)) ? ":" : "",
@@ -3039,12 +3038,12 @@
 		grp = g_slist_next(grp);
 	}
 
-	while (plist) {
+	while (len > pos && plist) {
 		pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data);
 		plist = plist->next;
 	}
 
-	while (dlist) {
+	while (len > pos && dlist) {
 		pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data);
 		dlist = dlist->next;
 	}
--- a/src/protocols/toc/toc.c	Thu Sep 13 22:57:53 2001 +0000
+++ b/src/protocols/toc/toc.c	Thu Sep 13 23:42:44 2001 +0000
@@ -221,20 +221,21 @@
 		 * so we just return here like everything went through fine */
 		return 0;
 
+	if (olen < 0)
+		len = escape_message(buf);
+	else
+		len = olen;
+
 	/* One _last_ 2048 check here!  This shouldn't ever
 	   * get hit though, hopefully.  If it gets hit on an IM
 	   * It'll lose the last " and the message won't go through,
 	   * but this'll stop a segfault. */
-	if (strlen(buf) > (MSG_LEN - sizeof(hdr))) {
+	if (len > MSG_LEN) {
 		debug_printf("message too long, truncating\n");
-		buf[MSG_LEN - sizeof(hdr) - 3] = '"';
-		buf[MSG_LEN - sizeof(hdr) - 2] = '\0';
+		buf[MSG_LEN - 1] = '\0';
+		len = MSG_LEN;
 	}
 
-	if (olen < 0)
-		len = escape_message(buf);
-	else
-		len = olen;
 	hdr.ast = '*';
 	hdr.type = type;
 	hdr.seqno = htons(tdt->seqno++ & 0xffff);
@@ -759,10 +760,11 @@
 
 static void toc_set_config(struct gaim_connection *gc)
 {
-	char buf[MSG_LEN], snd[BUF_LEN * 2];
-	toc_build_config(gc, buf, MSG_LEN, FALSE);
+	char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2];
+	toc_build_config(gc, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE);
 	g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf);
 	sflap_send(gc, snd, -1, TYPE_DATA);
+	g_free(buf);
 }
 
 static void toc_get_info(struct gaim_connection *g, char *name)