pidgin: 779433e1: Replace numerous strcpy() invocations wi...
elb at pidgin.im
elb at pidgin.im
Thu Aug 11 10:51:39 EDT 2011
----------------------------------------------------------------------
Revision: 779433e1b17424fac62edf24400ed2074bc4a468
Parent: 28e56bcfcccffd242b68d68c61e9df6e7ee87cc4
Author: elb at pidgin.im
Date: 07/16/11 23:57:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/779433e1b17424fac62edf24400ed2074bc4a468
Changelog:
Replace numerous strcpy() invocations with strlcpy() in Zephyr.
Thanks to the Electronic Frontier Foundation (http://www.eff.org/) for
this patch.
Changes against parent 28e56bcfcccffd242b68d68c61e9df6e7ee87cc4
patched libpurple/protocols/zephyr/ZAsyncLocate.c
patched libpurple/protocols/zephyr/ZInit.c
patched libpurple/protocols/zephyr/ZRetSubs.c
patched libpurple/protocols/zephyr/Zinternal.c
patched libpurple/protocols/zephyr/zephyr.c
-------------- next part --------------
============================================================
--- libpurple/protocols/zephyr/ZAsyncLocate.c 8bd283c5c76313e52c9f9dd151599517e3bf17bc
+++ libpurple/protocols/zephyr/ZAsyncLocate.c 0b72496d3138a4fd94f3a3325a31f08599eb86c4
@@ -45,8 +45,8 @@ Code_t ZRequestLocations(user, zald, kin
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 @@ Code_t ZParseLocations(notice,zald,nlocs
__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 @@ Code_t ZParseLocations(notice,zald,nlocs
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);
============================================================
--- libpurple/protocols/zephyr/ZInit.c 4dca7a39649cb7584b1d1a5a2830edc1c981e9dd
+++ libpurple/protocols/zephyr/ZInit.c c88ece4673abbbf62adfb1074331f1a1838884d7
@@ -101,14 +101,14 @@ Code_t ZInitialize()
#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;
============================================================
--- libpurple/protocols/zephyr/ZRetSubs.c 17f7abfea3676c134e63c8e69ec0f5c9e0be882f
+++ libpurple/protocols/zephyr/ZRetSubs.c 83bbe26d2b017a03af93c865e0b2f1e790392e52
@@ -147,7 +147,7 @@ static Code_t Z_RetSubs(notice, nsubs, a
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 @@ static Code_t Z_RetSubs(notice, nsubs, a
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 @@ static Code_t Z_RetSubs(notice, nsubs, a
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);
============================================================
--- libpurple/protocols/zephyr/Zinternal.c 7e19a554820617706bf9e0b472b325f67d19a61e
+++ libpurple/protocols/zephyr/Zinternal.c 1ac51889c8a53a88cb95997022376d822f734ba5
@@ -677,7 +677,7 @@ Code_t Z_FormatRawHeader(notice, buffer,
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 @@ Z_AddField(char **ptr, const char *field
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;
============================================================
--- libpurple/protocols/zephyr/zephyr.c f236ae11f9522c76f54fce85e1df41f42cdbadbe
+++ libpurple/protocols/zephyr/zephyr.c 6a482da35b03ebe95b82b74e2697bc2269de6c8a
@@ -2235,7 +2235,7 @@ static const char *zephyr_normalize(cons
return NULL;
}
- strcpy(buf, tmp);
+ g_strlcpy(buf, tmp, sizeof(buf));
g_free(tmp);
return buf;
More information about the Commits
mailing list