comparison libpurple/dnssrv.c @ 16914:11a0f2b4ac83

If the read() in resolved() fails, we should detect the failure and set size (which it would otherwise set, since it is passed by reference) to 0 and res to NULL. This ''may'' fix a rather odd crash described in Adium Trac #6623 (http://trac.adiumx.com/ticket/6623), and it is certainly good sanity checking.
author Evan Schoenberg <evan.s@dreskin.net>
date Sat, 05 May 2007 18:29:49 +0000
parents c028fc690b5d
children 3c6bc8785af9
comparison
equal deleted inserted replaced
16912:f9e7a7dacda3 16914:11a0f2b4ac83
190 PurpleSrvResponse *tmp; 190 PurpleSrvResponse *tmp;
191 int i; 191 int i;
192 PurpleSrvCallback cb = query_data->cb; 192 PurpleSrvCallback cb = query_data->cb;
193 int status; 193 int status;
194 194
195 read(source, &size, sizeof(int)); 195 if (read(source, &size, sizeof(int)) > 0)
196 purple_debug_info("dnssrv","found %d SRV entries\n", size); 196 {
197 tmp = res = g_new0(PurpleSrvResponse, size); 197 purple_debug_info("dnssrv","found %d SRV entries\n", size);
198 for (i = 0; i < size; i++) { 198 tmp = res = g_new0(PurpleSrvResponse, size);
199 read(source, tmp++, sizeof(PurpleSrvResponse)); 199 for (i = 0; i < size; i++) {
200 read(source, tmp++, sizeof(PurpleSrvResponse));
201 }
202 }
203 else
204 {
205 purple_debug_info("dnssrv","found 0 SRV entries; errno is %i\n", errno);
206 size = 0;
207 res = NULL;
200 } 208 }
201 209
202 cb(res, size, query_data->extradata); 210 cb(res, size, query_data->extradata);
203 waitpid(query_data->pid, &status, 0); 211 waitpid(query_data->pid, &status, 0);
204 212