aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2015-06-22 15:32:05 -0400
committerjgeboski <jgeboski@gmail.com>2015-06-22 15:32:05 -0400
commitbacc420b42c5e844d2d411f8bd4315e3410777eb (patch)
treecc10e1bcdad2862abee6d8d878f48134acfc4278
parent0d024c77f3105a7bb2d40821b63c969ce5beda72 (diff)
downloadbitlbee-facebook-bacc420b42c5e844d2d411f8bd4315e3410777eb.tar.gz
bitlbee-facebook-bacc420b42c5e844d2d411f8bd4315e3410777eb.tar.bz2
bitlbee-facebook-bacc420b42c5e844d2d411f8bd4315e3410777eb.tar.xz
facebook-thrift: fixed improper 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.
-rw-r--r--facebook/facebook-thrift.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/facebook/facebook-thrift.c b/facebook/facebook-thrift.c
index 13af9f4..ec49333 100644
--- a/facebook/facebook-thrift.c
+++ b/facebook/facebook-thrift.c
@@ -422,13 +422,19 @@ gboolean fb_thrift_read_vi64(fb_thrift_t *thft, guint64 *u64)
**/
gboolean fb_thrift_read_str(fb_thrift_t *thft, gchar **str)
{
- gint32 size;
- guint8 *data;
+ guint32 size;
+ guint8 *data;
+ gboolean res;
if (str != NULL)
*str = NULL;
- if (!fb_thrift_read_i32(thft, &size))
+ if (thft->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;
if (str != NULL) {
@@ -883,7 +889,12 @@ void fb_thrift_write_str(fb_thrift_t *thft, const gchar *str)
g_return_if_fail(str != NULL);
size = strlen(str);
- fb_thrift_write_vi32(thft, size);
+
+ if (thft->flags & FB_THRIFT_FLAG_COMPACT)
+ fb_thrift_write_vi32(thft, size);
+ else
+ fb_thrift_write_i32(thft, size);
+
fb_thrift_write(thft, str, size);
}