/soc/2015/jgeboski/facebook: 2dac11959ea1: facebook: fixed impro...

James Geboski jgeboski at gmail.com
Tue Jun 23 17:16:15 EDT 2015


Changeset: 2dac11959ea131605a2d28eb7efda70a72aabbba
Author:	 James Geboski <jgeboski at gmail.com>
Date:	 2015-06-22 16:26 -0400
Branch:	 facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/2dac11959ea1

Description:

facebook: fixed improper thrift string sizes

The thrift string functions were not correctly adjusting for compact
and non-compact strings, it was just assumed as one or the other.

diffstat:

 libpurple/protocols/facebook/thrift.c |  26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diffs (54 lines):

diff --git a/libpurple/protocols/facebook/thrift.c b/libpurple/protocols/facebook/thrift.c
--- a/libpurple/protocols/facebook/thrift.c
+++ b/libpurple/protocols/facebook/thrift.c
@@ -385,14 +385,25 @@ fb_thrift_read_vi64(FbThrift *thft, guin
 gboolean
 fb_thrift_read_str(FbThrift *thft, gchar **str)
 {
-	gint32 size;
+	FbThriftPrivate *priv;
+	gboolean res;
 	guint8 *data;
+	guint32 size;
+
+	g_return_val_if_fail(FB_IS_THRIFT(thft), FALSE);
+	priv = thft->priv;
 
 	if (str != NULL) {
 		*str = NULL;
 	}
 
-	if (!fb_thrift_read_i32(thft, &size)) {
+	if (priv->flags & FB_THRIFT_FLAG_COMPACT) {
+		res = fb_thrift_read_vi32(thft, &size);
+	} else {
+		res = fb_thrift_read_i32(thft, (gint32*) &size);
+	}
+
+	if (!res) {
 		return FALSE;
 	}
 
@@ -769,12 +780,21 @@ fb_thrift_write_vi64(FbThrift *thft, gui
 void
 fb_thrift_write_str(FbThrift *thft, const gchar *str)
 {
+	FbThriftPrivate *priv;
 	guint32 size;
 
+	g_return_if_fail(FB_IS_THRIFT(thft));
 	g_return_if_fail(str != NULL);
 
+	priv = thft->priv;
 	size = strlen(str);
-	fb_thrift_write_vi32(thft, size);
+
+	if (priv->flags & FB_THRIFT_FLAG_COMPACT) {
+		fb_thrift_write_vi32(thft, size);
+	} else {
+		fb_thrift_write_i32(thft, size);
+	}
+
 	fb_thrift_write(thft, str, size);
 }
 



More information about the Commits mailing list