# HG changeset patch # User Ethan Blanton # Date 1310875041 0 # Node ID 5d442ea707b58c018041253a7a2b6164d2dd7599 # Parent aeff9586f987ae0491a607be883f1b6349319c42 Replace numerous strcpy() invocations with strlcpy() in Zephyr. Thanks to the Electronic Frontier Foundation (http://www.eff.org/) for this patch. diff -r aeff9586f987 -r 5d442ea707b5 libpurple/protocols/zephyr/ZAsyncLocate.c --- a/libpurple/protocols/zephyr/ZAsyncLocate.c Sun Jul 17 03:56:39 2011 +0000 +++ b/libpurple/protocols/zephyr/ZAsyncLocate.c Sun Jul 17 03:57:21 2011 +0000 @@ -45,8 +45,8 @@ return(ENOMEM); } zald->uid = notice.z_multiuid; - strcpy(zald->user,user); - strcpy(zald->version,notice.z_version); + g_strlcpy(zald->user,user,strlen(user)+1); + g_strlcpy(zald->version,notice.z_version,strlen(notice.z_version)+1); return(ZERR_NONE); } @@ -109,21 +109,21 @@ __locate_list[i].host = (char *) malloc(len); if (!__locate_list[i].host) return (ENOMEM); - (void) strcpy(__locate_list[i].host, ptr); + g_strlcpy(__locate_list[i].host, ptr,len); ptr += len; len = strlen (ptr) + 1; __locate_list[i].time = (char *) malloc(len); if (!__locate_list[i].time) return (ENOMEM); - (void) strcpy(__locate_list[i].time, ptr); + g_strlcpy(__locate_list[i].time, ptr,len); ptr += len; len = strlen (ptr) + 1; __locate_list[i].tty = (char *) malloc(len); if (!__locate_list[i].tty) return (ENOMEM); - (void) strcpy(__locate_list[i].tty, ptr); + g_strlcpy(__locate_list[i].tty, ptr,len); ptr += len; } @@ -133,11 +133,11 @@ if (zald) { if ((*user = (char *) malloc(strlen(zald->user)+1)) == NULL) return(ENOMEM); - strcpy(*user,zald->user); + g_strlcpy(*user,zald->user,strlen(zald->user)+1); } else { if ((*user = (char *) malloc(strlen(notice->z_class_inst)+1)) == NULL) return(ENOMEM); - strcpy(*user,notice->z_class_inst); + g_strlcpy(*user,notice->z_class_inst,strlen(notice->z_class_inst)+1); } } return (ZERR_NONE); diff -r aeff9586f987 -r 5d442ea707b5 libpurple/protocols/zephyr/ZInit.c --- a/libpurple/protocols/zephyr/ZInit.c Sun Jul 17 03:56:39 2011 +0000 +++ b/libpurple/protocols/zephyr/ZInit.c Sun Jul 17 03:57:21 2011 +0000 @@ -101,14 +101,14 @@ #ifdef ZEPHYR_USES_KERBEROS if (krealm) { - strcpy(__Zephyr_realm, krealm); + g_strlcpy(__Zephyr_realm, krealm, REALM_SZ-1); } else if ((krb_get_tf_fullname(TKT_FILE, d1, d2, __Zephyr_realm) != KSUCCESS) && ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS)) { return (krbval); } #else - strcpy(__Zephyr_realm, "local-realm"); + g_strlcpy(__Zephyr_realm, "local-realm", 12); #endif __My_addr.s_addr = INADDR_NONE; diff -r aeff9586f987 -r 5d442ea707b5 libpurple/protocols/zephyr/ZRetSubs.c --- a/libpurple/protocols/zephyr/ZRetSubs.c Sun Jul 17 03:56:39 2011 +0000 +++ b/libpurple/protocols/zephyr/ZRetSubs.c Sun Jul 17 03:57:21 2011 +0000 @@ -147,7 +147,7 @@ ZFreeNotice(&retnotice); return (ENOMEM); } - (void) strcpy(__subscriptions_list[i].zsub_class,ptr); + g_strlcpy(__subscriptions_list[i].zsub_class,ptr,(unsigned)strlen(ptr)); ptr += strlen(ptr)+1; __subscriptions_list[i].zsub_classinst = (char *) malloc((unsigned)strlen(ptr)+1); @@ -155,7 +155,7 @@ ZFreeNotice(&retnotice); return (ENOMEM); } - (void) strcpy(__subscriptions_list[i].zsub_classinst,ptr); + g_strlcpy(__subscriptions_list[i].zsub_classinst,ptr,(unsigned)strlen(ptr)); ptr += strlen(ptr)+1; ptr2 = ptr; if (!*ptr2) @@ -166,7 +166,7 @@ ZFreeNotice(&retnotice); return (ENOMEM); } - (void) strcpy(__subscriptions_list[i].zsub_recipient,ptr2); + g_strlcpy(__subscriptions_list[i].zsub_recipient,ptr2,(unsigned)strlen(ptr2)); ptr += strlen(ptr)+1; } ZFreeNotice(&retnotice); diff -r aeff9586f987 -r 5d442ea707b5 libpurple/protocols/zephyr/Zinternal.c --- a/libpurple/protocols/zephyr/Zinternal.c Sun Jul 17 03:56:39 2011 +0000 +++ b/libpurple/protocols/zephyr/Zinternal.c Sun Jul 17 03:57:21 2011 +0000 @@ -677,7 +677,7 @@ if (buffer_len < strlen(notice->z_version)+1) return (ZERR_HEADERLEN); - (void) strcpy(ptr, notice->z_version); + g_strlcpy(ptr, notice->z_version, buffer_len); ptr += strlen(ptr)+1; if (ZMakeAscii32(ptr, end-ptr, Z_NUMFIELDS + notice->z_num_other_fields) @@ -767,9 +767,9 @@ if (*ptr+len > end) return 1; if (field) - (void) strcpy(*ptr, field); + g_strlcpy(*ptr, field, len); else - **ptr = '\0'; + **ptr = '\0'; *ptr += len; return 0; diff -r aeff9586f987 -r 5d442ea707b5 libpurple/protocols/zephyr/zephyr.c --- a/libpurple/protocols/zephyr/zephyr.c Sun Jul 17 03:56:39 2011 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Sun Jul 17 03:57:21 2011 +0000 @@ -2235,7 +2235,7 @@ return NULL; } - strcpy(buf, tmp); + g_strlcpy(buf, tmp, sizeof(buf)); g_free(tmp); return buf;