comparison libpurple/protocols/mxit/actions.c @ 30288:d9e94339ca3b

For safety, rather use g_strlcpy() and snprintf() where possible.
author andrew.victor@mxit.com
date Mon, 19 Jul 2010 09:52:08 +0000
parents 08d9cdac2b3c
children 6d6ac5720853
comparison
equal deleted inserted replaced
30287:c2b3bfb2fe35 30288:d9e94339ca3b
123 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_HIDENUMBER, CP_PROFILE_TYPE_BOOL, ( profile->hidden ) ? "1" : "0" ); 123 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_HIDENUMBER, CP_PROFILE_TYPE_BOOL, ( profile->hidden ) ? "1" : "0" );
124 g_string_append( attributes, attrib ); 124 g_string_append( attributes, attrib );
125 acount++; 125 acount++;
126 126
127 /* update birthday */ 127 /* update birthday */
128 strcpy( profile->birthday, bday ); 128 g_strlcpy( profile->birthday, bday, sizeof( profile->birthday ) );
129 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday ); 129 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday );
130 g_string_append( attributes, attrib ); 130 g_string_append( attributes, attrib );
131 acount++; 131 acount++;
132 132
133 /* update gender */ 133 /* update gender */
139 /* update title */ 139 /* update title */
140 name = purple_request_fields_get_string( fields, "title" ); 140 name = purple_request_fields_get_string( fields, "title" );
141 if ( !name ) 141 if ( !name )
142 profile->title[0] = '\0'; 142 profile->title[0] = '\0';
143 else 143 else
144 strcpy( profile->title, name ); 144 g_strlcpy( profile->title, name, sizeof( profile->title ) );
145 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_TITLE, CP_PROFILE_TYPE_UTF8, profile->title ); 145 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_TITLE, CP_PROFILE_TYPE_UTF8, profile->title );
146 g_string_append( attributes, attrib ); 146 g_string_append( attributes, attrib );
147 acount++; 147 acount++;
148 148
149 /* update firstname */ 149 /* update firstname */
150 name = purple_request_fields_get_string( fields, "firstname" ); 150 name = purple_request_fields_get_string( fields, "firstname" );
151 if ( !name ) 151 if ( !name )
152 profile->firstname[0] = '\0'; 152 profile->firstname[0] = '\0';
153 else 153 else
154 strcpy( profile->firstname, name ); 154 g_strlcpy( profile->firstname, name, sizeof( profile->firstname ) );
155 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FIRSTNAME, CP_PROFILE_TYPE_UTF8, profile->firstname ); 155 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FIRSTNAME, CP_PROFILE_TYPE_UTF8, profile->firstname );
156 g_string_append( attributes, attrib ); 156 g_string_append( attributes, attrib );
157 acount++; 157 acount++;
158 158
159 /* update lastname */ 159 /* update lastname */
160 name = purple_request_fields_get_string( fields, "lastname" ); 160 name = purple_request_fields_get_string( fields, "lastname" );
161 if ( !name ) 161 if ( !name )
162 profile->lastname[0] = '\0'; 162 profile->lastname[0] = '\0';
163 else 163 else
164 strcpy( profile->lastname, name ); 164 g_strlcpy( profile->lastname, name, sizeof( profile->lastname ) );
165 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_LASTNAME, CP_PROFILE_TYPE_UTF8, profile->lastname ); 165 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_LASTNAME, CP_PROFILE_TYPE_UTF8, profile->lastname );
166 g_string_append( attributes, attrib ); 166 g_string_append( attributes, attrib );
167 acount++; 167 acount++;
168 168
169 /* update email address */ 169 /* update email address */
170 name = purple_request_fields_get_string( fields, "email" ); 170 name = purple_request_fields_get_string( fields, "email" );
171 if ( !name ) 171 if ( !name )
172 profile->email[0] = '\0'; 172 profile->email[0] = '\0';
173 else 173 else
174 strcpy( profile->email, name ); 174 g_strlcpy( profile->email, name, sizeof( profile->email ) );
175 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_EMAIL, CP_PROFILE_TYPE_UTF8, profile->email ); 175 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_EMAIL, CP_PROFILE_TYPE_UTF8, profile->email );
176 g_string_append( attributes, attrib ); 176 g_string_append( attributes, attrib );
177 acount++; 177 acount++;
178 178
179 /* update mobile number */ 179 /* update mobile number */
180 name = purple_request_fields_get_string( fields, "mobilenumber" ); 180 name = purple_request_fields_get_string( fields, "mobilenumber" );
181 if ( !name ) 181 if ( !name )
182 profile->mobilenr[0] = '\0'; 182 profile->mobilenr[0] = '\0';
183 else 183 else
184 strcpy( profile->mobilenr, name ); 184 g_strlcpy( profile->mobilenr, name, sizeof( profile->mobilenr ) );
185 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_MOBILENR, CP_PROFILE_TYPE_UTF8, profile->mobilenr ); 185 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_MOBILENR, CP_PROFILE_TYPE_UTF8, profile->mobilenr );
186 g_string_append( attributes, attrib ); 186 g_string_append( attributes, attrib );
187 acount++; 187 acount++;
188 188
189 /* send the profile update to MXit */ 189 /* send the profile update to MXit */