/soc/2013/ankitkv/gobjectification: 3f68e191c0a0: Merged default...
Ankit Vani
a at nevitus.org
Thu Jul 11 19:34:28 EDT 2013
Changeset: 3f68e191c0a00987a4ddba5c6c10bb8749504459
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-12 05:04 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/3f68e191c0a0
Description:
Merged default branch
diffstat:
libpurple/plugins/ssl/ssl-nss.c | 50 +++++++++++++++++++++++++++++++++++++-
libpurple/protocols/mxit/markup.c | 45 ++++++++++++++---------------------
libpurple/util.c | 31 +++++++++++++----------
3 files changed, 83 insertions(+), 43 deletions(-)
diffs (300 lines):
diff --git a/libpurple/plugins/ssl/ssl-nss.c b/libpurple/plugins/ssl/ssl-nss.c
--- a/libpurple/plugins/ssl/ssl-nss.c
+++ b/libpurple/plugins/ssl/ssl-nss.c
@@ -29,7 +29,15 @@
#define SSL_NSS_PLUGIN_ID "ssl-nss"
+#ifdef _WIN32
+# ifndef HAVE_LONG_LONG
+#define HAVE_LONG_LONG
+# endif
+#else
+/* TODO: Why is this done?
+ * This is probably being overridden by <nspr.h> (prcpucfg.h) on *nix OSes */
#undef HAVE_LONG_LONG /* Make Mozilla less angry. If angry, Mozilla SMASH! */
+#endif
#include <nspr.h>
#include <nss.h>
@@ -910,11 +918,49 @@ x509_times (PurpleCertificate *crt, time
/* NSS's native PRTime type *almost* corresponds to time_t; however,
it measures *microseconds* since the epoch, not seconds. Hence
the funny conversion. */
+ nss_activ = nss_activ / 1000000;
+ nss_expir = nss_expir / 1000000;
+
if (activation) {
- *activation = nss_activ / 1000000;
+ *activation = nss_activ;
+#if SIZEOF_TIME_T == 4
+ /** Hack to deal with dates past the 32-bit barrier.
+ Handling is different for signed vs unsigned 32-bit types.
+ */
+ if (*activation != nss_activ) {
+ if (nss_activ < 0) {
+ purple_debug_warning("nss",
+ "Setting Activation Date to epoch to handle pre-epoch value\n");
+ *activation = 0;
+ } else {
+ purple_debug_error("nss",
+ "Activation date past 32-bit barrier, forcing invalidity\n");
+ return FALSE;
+ }
+ }
+#endif
}
if (expiration) {
- *expiration = nss_expir / 1000000;
+ *expiration = nss_expir;
+#if SIZEOF_TIME_T == 4
+ if (*expiration != nss_expir) {
+ if (*expiration < nss_expir) {
+ if (*expiration < 0) {
+ purple_debug_warning("nss",
+ "Setting Expiration Date to 32-bit signed max\n");
+ *expiration = PR_INT32_MAX;
+ } else {
+ purple_debug_warning("nss",
+ "Setting Expiration Date to 32-bit unsigned max\n");
+ *expiration = PR_UINT32_MAX;
+ }
+ } else {
+ purple_debug_error("nss",
+ "Expiration date prior to unix epoch, forcing invalidity\n");
+ return FALSE;
+ }
+ }
+#endif
}
return TRUE;
diff --git a/libpurple/protocols/mxit/markup.c b/libpurple/protocols/mxit/markup.c
--- a/libpurple/protocols/mxit/markup.c
+++ b/libpurple/protocols/mxit/markup.c
@@ -87,7 +87,7 @@ static const char* vibes[] = {
* @param buf The data to dump
* @param len The length of the data
*/
-static void hex_dump( const char* buf, int len )
+static void hex_dump( const gchar* buf, int len )
{
char msg[256];
int pos;
@@ -103,11 +103,11 @@ static void hex_dump( const char* buf, i
if ( pos == 0 )
pos += sprintf( &msg[pos], "%04i: ", i );
- pos += sprintf( &msg[pos], "0x%02X ", (unsigned char) buf[i] );
+ pos += sprintf( &msg[pos], "0x%02X ", buf[i] );
if ( i % 16 == 15 ) {
pos += sprintf( &msg[pos], "\n" );
- purple_debug_info( MXIT_PLUGIN_ID, msg );
+ purple_debug_info( MXIT_PLUGIN_ID, "%s", msg );
pos = 0;
}
else if ( i % 16 == 7 )
@@ -116,7 +116,7 @@ static void hex_dump( const char* buf, i
if ( pos > 0 ) {
pos += sprintf( &msg[pos], "\n" );
- purple_debug_info( MXIT_PLUGIN_ID, msg );
+ purple_debug_info( MXIT_PLUGIN_ID, "%s", msg );
pos = 0;
}
}
@@ -167,7 +167,7 @@ void mxit_add_html_link( struct RXMsgDat
* @param size The extracted length
* @return The number of bytes extracted
*/
-static unsigned int asn_getlength( const char* data, int* size )
+static unsigned int asn_getlength( const gchar* data, int* size )
{
unsigned int len = 0;
unsigned char bytes;
@@ -202,14 +202,14 @@ static unsigned int asn_getlength( const
* @param utf8 The extracted string. Must be deallocated by caller.
* @return The number of bytes extracted
*/
-static int asn_getUtf8( const char* data, unsigned char type, char** utf8 )
+static int asn_getUtf8( const gchar* data, gchar type, char** utf8 )
{
int len;
/* validate the field type [1 byte] */
if ( data[0] != type ) {
/* this is not a utf-8 string! */
- purple_debug_error( MXIT_PLUGIN_ID, "Invalid UTF-8 encoded string in ASN data (0x%02X)\n", (unsigned char) data[0] );
+ purple_debug_error( MXIT_PLUGIN_ID, "Invalid UTF-8 encoded string in ASN data (got 0x%02X, expected 0x%02X)\n", data[0], type );
return -1;
}
@@ -472,7 +472,6 @@ static void emoticon_returned(PurpleHttp
const gchar* data;
size_t len;
unsigned int pos = 0;
- char emo[16];
int id;
char* str;
int em_size = 0;
@@ -481,9 +480,7 @@ static void emoticon_returned(PurpleHttp
int* intptr = NULL;
int res;
-#ifdef MXIT_DEBUG_EMO
purple_debug_info( MXIT_PLUGIN_ID, "emoticon_returned\n" );
-#endif
/* remove request from the async outstanding calls list */
mx->session->async_http_reqs = g_slist_remove(mx->session->async_http_reqs, http_conn);
@@ -500,12 +497,8 @@ static void emoticon_returned(PurpleHttp
hex_dump( data, len );
#endif
- /* parse out the emoticon */
- pos = 0;
-
- /* validate the binary data received from the wapsite */
+ /* validate that the returned data starts with the magic constant that indicates it is a custom emoticon */
if ( memcmp( MXIT_FRAME_MAGIC, &data[pos], strlen( MXIT_FRAME_MAGIC ) ) != 0 ) {
- /* bad data, magic constant is wrong */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid emoticon received from wapsite (bad magic)\n" );
goto done;
}
@@ -513,16 +506,14 @@ static void emoticon_returned(PurpleHttp
/* validate the image frame desc byte */
if ( data[pos] != '\x6F' ) {
- /* bad frame desc */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid emoticon received from wapsite (bad frame desc)\n" );
goto done;
}
pos++;
- /* get the data length */
+ /* get the frame image data length */
res = asn_getlength( &data[pos], &em_size );
if ( res <= 0 ) {
- /* bad frame length */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid emoticon received from wapsite (bad frame length)\n" );
goto done;
}
@@ -534,7 +525,6 @@ static void emoticon_returned(PurpleHttp
/* utf-8 (emoticon name) */
res = asn_getUtf8( &data[pos], 0x0C, &str );
if ( res <= 0 ) {
- /* bad utf-8 string */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid emoticon received from wapsite (bad name string)\n" );
goto done;
}
@@ -548,7 +538,6 @@ static void emoticon_returned(PurpleHttp
/* utf-8 (emoticon shortcut) */
res = asn_getUtf8( &data[pos], 0x81, &str );
if ( res <= 0 ) {
- /* bad utf-8 string */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid emoticon received from wapsite (bad shortcut string)\n" );
goto done;
}
@@ -560,7 +549,6 @@ static void emoticon_returned(PurpleHttp
/* validate the image data type */
if ( data[pos] != '\x82' ) {
- /* bad frame desc */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid emoticon received from wapsite (bad data type)\n" );
g_free( em_id );
goto done;
@@ -580,8 +568,17 @@ static void emoticon_returned(PurpleHttp
purple_debug_info( MXIT_PLUGIN_ID, "read the length '%i'\n", em_size );
#endif
+ /* strip the mxit markup tags from the emoticon id (eg, .{XY} -> XY) */
+ if ( ( em_id[0] == '.' ) && ( em_id[1] == '{' ) ) {
+ char emo[MXIT_MAX_EMO_ID + 1];
+
+ parse_emoticon_str( &em_id[2], emo );
+ strcpy( em_id, emo );
+ }
+
if ( g_hash_table_lookup( mx->session->iimages, em_id ) ) {
/* emoticon found in the table, so ignore this one */
+ g_free( em_id );
goto done;
}
@@ -589,12 +586,6 @@ static void emoticon_returned(PurpleHttp
em_data = g_malloc( em_size );
memcpy( em_data, &data[pos], em_size );
- /* strip the mxit markup tags from the emoticon id */
- if ( ( em_id[0] == '.' ) && ( em_id[1] == '{' ) ) {
- parse_emoticon_str( &em_id[2], emo );
- strcpy( em_id, emo );
- }
-
/* we now have the emoticon, store it in the imagestore */
id = purple_imgstore_new_with_id( em_data, em_size, NULL );
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -740,7 +740,7 @@ purple_str_to_time(const char *timestamp
gint year = 0;
long tzoff = PURPLE_NO_TZ_OFF;
time_t retval;
- gboolean mktime_with_utc = TRUE;
+ gboolean mktime_with_utc = FALSE;
if (rest != NULL)
*rest = NULL;
@@ -841,7 +841,7 @@ purple_str_to_time(const char *timestamp
} while (*str >= '0' && *str <= '9');
}
- sign = (*str == '+') ? -1 : 1;
+ sign = (*str == '+') ? 1 : -1;
/* Process the timezone */
if (*str == '+' || *str == '-') {
@@ -850,26 +850,29 @@ purple_str_to_time(const char *timestamp
if (((sscanf(str, "%02d:%02d", &tzhrs, &tzmins) == 2 && (str += 5)) ||
(sscanf(str, "%02d%02d", &tzhrs, &tzmins) == 2 && (str += 4))))
{
+ mktime_with_utc = TRUE;
tzoff = tzhrs * 60 * 60 + tzmins * 60;
tzoff *= sign;
- } else {
- if (rest != NULL && *str != '\0')
- *rest = str;
-
- return 0;
}
} else if (*str == 'Z') {
/* 'Z' = Zulu = UTC */
str++;
- utc = TRUE;
- } else if (!utc) {
- /* Local Time */
- t.tm_isdst = -1;
- mktime_with_utc = FALSE;
+ mktime_with_utc = TRUE;
+ tzoff = 0;
}
- if (utc)
- tzoff = 0;
+ if (!mktime_with_utc)
+ {
+ /* No timezone specified. */
+
+ if (utc) {
+ mktime_with_utc = TRUE;
+ tzoff = 0;
+ } else {
+ /* Local Time */
+ t.tm_isdst = -1;
+ }
+ }
}
}
More information about the Commits
mailing list