Mercurial > pidgin.yaz
changeset 32229:680bd9ef2d8f
Fix up Zephyr g_strlcpy patch
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Sun, 17 Jul 2011 17:17:19 +0000 |
parents | 5d442ea707b5 |
children | d5a00aa868f3 |
files | libpurple/protocols/zephyr/ZAsyncLocate.c libpurple/protocols/zephyr/ZInit.c libpurple/protocols/zephyr/ZRetSubs.c |
diffstat | 3 files changed, 28 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/zephyr/ZAsyncLocate.c Sun Jul 17 03:57:21 2011 +0000 +++ b/libpurple/protocols/zephyr/ZAsyncLocate.c Sun Jul 17 17:17:19 2011 +0000 @@ -18,6 +18,7 @@ { int retval; ZNotice_t notice; + size_t userlen, versionlen; if (ZGetFD() < 0) if ((retval = ZOpenPort((unsigned short *)0)) != ZERR_NONE) @@ -37,16 +38,18 @@ if ((retval = ZSendNotice(¬ice, auth)) != ZERR_NONE) return(retval); - if ((zald->user = (char *) malloc(strlen(user)+1)) == NULL) { + userlen = strlen(user) + 1; + versionlen = strlen(notice.z_version) + 1; + if ((zald->user = (char *) malloc(userlen)) == NULL) { return(ENOMEM); } - if ((zald->version = (char *) malloc(strlen(notice.z_version)+1)) == NULL) { + if ((zald->version = (char *) malloc(versionlen)) == NULL) { free(zald->user); return(ENOMEM); } zald->uid = notice.z_multiuid; - g_strlcpy(zald->user,user,strlen(user)+1); - g_strlcpy(zald->version,notice.z_version,strlen(notice.z_version)+1); + g_strlcpy(zald->user,user,userlen); + g_strlcpy(zald->version,notice.z_version,versionlen); return(ZERR_NONE); } @@ -130,14 +133,17 @@ __locate_next = 0; *nlocs = __locate_num; if (user) { + size_t len; if (zald) { - if ((*user = (char *) malloc(strlen(zald->user)+1)) == NULL) + len = strlen(zald->user) + 1; + if ((*user = (char *) malloc(len)) == NULL) return(ENOMEM); - g_strlcpy(*user,zald->user,strlen(zald->user)+1); + g_strlcpy(*user,zald->user,len); } else { - if ((*user = (char *) malloc(strlen(notice->z_class_inst)+1)) == NULL) + len = strlen(notice->z_class_inst) + 1; + if ((*user = (char *) malloc(len)) == NULL) return(ENOMEM); - g_strlcpy(*user,notice->z_class_inst,strlen(notice->z_class_inst)+1); + g_strlcpy(*user,notice->z_class_inst,len); } } return (ZERR_NONE);
--- a/libpurple/protocols/zephyr/ZInit.c Sun Jul 17 03:57:21 2011 +0000 +++ b/libpurple/protocols/zephyr/ZInit.c Sun Jul 17 17:17:19 2011 +0000 @@ -101,7 +101,7 @@ #ifdef ZEPHYR_USES_KERBEROS if (krealm) { - g_strlcpy(__Zephyr_realm, krealm, REALM_SZ-1); + g_strlcpy(__Zephyr_realm, krealm, REALM_SZ); } else if ((krb_get_tf_fullname(TKT_FILE, d1, d2, __Zephyr_realm) != KSUCCESS) && ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS)) {
--- a/libpurple/protocols/zephyr/ZRetSubs.c Sun Jul 17 03:57:21 2011 +0000 +++ b/libpurple/protocols/zephyr/ZRetSubs.c Sun Jul 17 17:17:19 2011 +0000 @@ -141,32 +141,37 @@ } for (ptr=retnotice.z_message,i = 0; i< __subscriptions_num; i++) { + size_t len; + + len = strlen(ptr) + 1; __subscriptions_list[i].zsub_class = (char *) - malloc((unsigned)strlen(ptr)+1); + malloc(len); if (!__subscriptions_list[i].zsub_class) { ZFreeNotice(&retnotice); return (ENOMEM); } - g_strlcpy(__subscriptions_list[i].zsub_class,ptr,(unsigned)strlen(ptr)); - ptr += strlen(ptr)+1; + g_strlcpy(__subscriptions_list[i].zsub_class,ptr,len); + ptr += len; + len = strlen(ptr) + 1; __subscriptions_list[i].zsub_classinst = (char *) - malloc((unsigned)strlen(ptr)+1); + malloc(len); if (!__subscriptions_list[i].zsub_classinst) { ZFreeNotice(&retnotice); return (ENOMEM); } - g_strlcpy(__subscriptions_list[i].zsub_classinst,ptr,(unsigned)strlen(ptr)); - ptr += strlen(ptr)+1; + g_strlcpy(__subscriptions_list[i].zsub_classinst,ptr,len); + ptr += len; ptr2 = ptr; if (!*ptr2) ptr2 = "*"; + len = strlen(ptr2) + 1; __subscriptions_list[i].zsub_recipient = (char *) - malloc((unsigned)strlen(ptr2)+1); + malloc(len); if (!__subscriptions_list[i].zsub_recipient) { ZFreeNotice(&retnotice); return (ENOMEM); } - g_strlcpy(__subscriptions_list[i].zsub_recipient,ptr2,(unsigned)strlen(ptr2)); + g_strlcpy(__subscriptions_list[i].zsub_recipient,ptr2,len); ptr += strlen(ptr)+1; } ZFreeNotice(&retnotice);