changeset 11188:12fc7a3fbc88

[gaim-migrate @ 13305] It'll be nice not to crash when logging in with the wrong password. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 04 Aug 2005 01:08:01 +0000
parents 744c0708d11f
children 5f79dfde334c
files src/protocols/yahoo/yahoo.c
diffstat 1 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Wed Aug 03 23:54:37 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Thu Aug 04 01:08:01 2005 +0000
@@ -2300,17 +2300,28 @@
 	const char *c = buf;
 	char *d;
 	char name[64], value[64];
-	int count = sizeof(name)-1;
-	while ((c < (buf + len)) && (c = strstr(c, "<input "))) {
-		c = strstr(c, "name=\"") + strlen("name=\"");
-		for (d = name; *c!='"' && count; c++, d++, count--)
+	int count;
+	int input_len = strlen("<input ");
+	int name_len = strlen("name=\"");
+	int value_len = strlen("value=\"");
+	while ((len > ((c - buf) + input_len))
+			&& (c = strstr(c, "<input "))) {
+		if (!(c = g_strstr_len(c, len - (c - buf), "name=\"")))
+			continue;
+		c += name_len;
+		count = sizeof(name)-1;
+		for (d = name; (len > ((c - buf) + 1)) && *c!='"'
+				&& count; c++, d++, count--)
 			*d = *c;
 		*d = '\0';
 		count = sizeof(value)-1;
-		d = strstr(c, "value=\"") + strlen("value=\"");
+		if (!(d = g_strstr_len(c, len - (c - buf), "value=\"")))
+			continue;
+		d += value_len;
 		if (strchr(c, '>') < d)
 			break;
-		for (c = d, d = value; *c!='"' && count; c++, d++, count--)
+		for (c = d, d = value; (len > ((c - buf) + 1))
+				&& *c!='"' && count; c++, d++, count--)
 			*d = *c;
 		*d = '\0';
 		g_hash_table_insert(hash, g_strdup(name), g_strdup(value));