Mercurial > pidgin
comparison libpurple/protocols/zephyr/ZAsyncLocate.c @ 31771: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 |
comparison
equal
deleted
inserted
replaced
31770:5d442ea707b5 | 31771:680bd9ef2d8f |
---|---|
16 ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */ | 16 ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */ |
17 Z_AuthProc auth; | 17 Z_AuthProc auth; |
18 { | 18 { |
19 int retval; | 19 int retval; |
20 ZNotice_t notice; | 20 ZNotice_t notice; |
21 size_t userlen, versionlen; | |
21 | 22 |
22 if (ZGetFD() < 0) | 23 if (ZGetFD() < 0) |
23 if ((retval = ZOpenPort((unsigned short *)0)) != ZERR_NONE) | 24 if ((retval = ZOpenPort((unsigned short *)0)) != ZERR_NONE) |
24 return (retval); | 25 return (retval); |
25 | 26 |
35 notice.z_message_len = 0; | 36 notice.z_message_len = 0; |
36 | 37 |
37 if ((retval = ZSendNotice(¬ice, auth)) != ZERR_NONE) | 38 if ((retval = ZSendNotice(¬ice, auth)) != ZERR_NONE) |
38 return(retval); | 39 return(retval); |
39 | 40 |
40 if ((zald->user = (char *) malloc(strlen(user)+1)) == NULL) { | 41 userlen = strlen(user) + 1; |
42 versionlen = strlen(notice.z_version) + 1; | |
43 if ((zald->user = (char *) malloc(userlen)) == NULL) { | |
41 return(ENOMEM); | 44 return(ENOMEM); |
42 } | 45 } |
43 if ((zald->version = (char *) malloc(strlen(notice.z_version)+1)) == NULL) { | 46 if ((zald->version = (char *) malloc(versionlen)) == NULL) { |
44 free(zald->user); | 47 free(zald->user); |
45 return(ENOMEM); | 48 return(ENOMEM); |
46 } | 49 } |
47 zald->uid = notice.z_multiuid; | 50 zald->uid = notice.z_multiuid; |
48 g_strlcpy(zald->user,user,strlen(user)+1); | 51 g_strlcpy(zald->user,user,userlen); |
49 g_strlcpy(zald->version,notice.z_version,strlen(notice.z_version)+1); | 52 g_strlcpy(zald->version,notice.z_version,versionlen); |
50 | 53 |
51 return(ZERR_NONE); | 54 return(ZERR_NONE); |
52 } | 55 } |
53 | 56 |
54 Code_t ZParseLocations(notice,zald,nlocs,user) | 57 Code_t ZParseLocations(notice,zald,nlocs,user) |
128 } | 131 } |
129 | 132 |
130 __locate_next = 0; | 133 __locate_next = 0; |
131 *nlocs = __locate_num; | 134 *nlocs = __locate_num; |
132 if (user) { | 135 if (user) { |
136 size_t len; | |
133 if (zald) { | 137 if (zald) { |
134 if ((*user = (char *) malloc(strlen(zald->user)+1)) == NULL) | 138 len = strlen(zald->user) + 1; |
139 if ((*user = (char *) malloc(len)) == NULL) | |
135 return(ENOMEM); | 140 return(ENOMEM); |
136 g_strlcpy(*user,zald->user,strlen(zald->user)+1); | 141 g_strlcpy(*user,zald->user,len); |
137 } else { | 142 } else { |
138 if ((*user = (char *) malloc(strlen(notice->z_class_inst)+1)) == NULL) | 143 len = strlen(notice->z_class_inst) + 1; |
144 if ((*user = (char *) malloc(len)) == NULL) | |
139 return(ENOMEM); | 145 return(ENOMEM); |
140 g_strlcpy(*user,notice->z_class_inst,strlen(notice->z_class_inst)+1); | 146 g_strlcpy(*user,notice->z_class_inst,len); |
141 } | 147 } |
142 } | 148 } |
143 return (ZERR_NONE); | 149 return (ZERR_NONE); |
144 } | 150 } |
145 | 151 |