- Timestamp:
- 2015-05-04T21:58:50Z (10 years ago)
- Children:
- 5726a0d
- Parents:
- 531eabd (diff), 5ca1416 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r531eabd rb1dc403 719 719 } 720 720 721 /* Make sure we're still inside the string */722 if (i >= len) {723 return(NULL);724 }725 726 721 /* Copy the found data */ 727 722 return(g_strndup(ret, text + i - ret)); -
lib/oauth.c
r531eabd rb1dc403 98 98 GSList *l, *n; 99 99 100 if ( params == NULL) {100 if (!params) { 101 101 return; 102 102 } … … 104 104 for (l = *params; l; l = n) { 105 105 n = l->next; 106 107 if (strncmp((char *) l->data, key, key_len) == 0 && 108 ((char *) l->data)[key_len] == '=') {109 g_free(l->data);110 *params = g_slist_remove(*params, l->data);106 char *data = l->data; 107 108 if (strncmp(data, key, key_len) == 0 && data[key_len] == '=') { 109 *params = g_slist_remove(*params, data); 110 g_free(data); 111 111 } 112 112 } -
lib/proxy.c
r531eabd rb1dc403 63 63 static int proxy_connect_none(const char *host, unsigned short port_, struct PHB *phb); 64 64 65 static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond) 65 static gboolean phb_close(struct PHB *phb) 66 { 67 close(phb->fd); 68 phb->func(phb->data, -1, B_EV_IO_READ); 69 g_free(phb->host); 70 g_free(phb); 71 return FALSE; 72 } 73 74 static gboolean proxy_connected(gpointer data, gint source, b_input_condition cond) 66 75 { 67 76 struct PHB *phb = data; … … 80 89 dup2(new_fd, source); 81 90 closesocket(new_fd); 82 phb->inpa = b_input_add(source, B_EV_IO_WRITE, gaim_io_connected, phb);91 phb->inpa = b_input_add(source, B_EV_IO_WRITE, proxy_connected, phb); 83 92 return FALSE; 84 93 } 85 94 } 86 freeaddrinfo(phb->gai);87 95 closesocket(source); 88 b_event_remove(phb->inpa); 89 phb->inpa = 0; 90 if (phb->proxy_func) { 91 phb->proxy_func(phb->proxy_data, -1, B_EV_IO_READ); 92 } else { 93 phb->func(phb->data, -1, B_EV_IO_READ); 94 g_free(phb); 95 } 96 return FALSE; 97 } 96 source = -1; 97 /* socket is dead, but continue to clean up */ 98 } else { 99 sock_make_blocking(source); 100 } 101 98 102 freeaddrinfo(phb->gai); 99 sock_make_blocking(source);100 103 b_event_remove(phb->inpa); 101 104 phb->inpa = 0; … … 160 163 continue; 161 164 } else { 162 phb->inpa = b_input_add(fd, B_EV_IO_WRITE, gaim_io_connected, phb);165 phb->inpa = b_input_add(fd, B_EV_IO_WRITE, proxy_connected, phb); 163 166 phb->fd = fd; 164 167 … … 206 209 } 207 210 208 close(source); 209 phb->func(phb->data, -1, B_EV_IO_READ); 210 g_free(phb->host); 211 g_free(phb); 212 213 return FALSE; 211 return phb_close(phb); 214 212 } 215 213 … … 226 224 len = sizeof(error); 227 225 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 228 close(source); 229 phb->func(phb->data, -1, B_EV_IO_READ); 230 g_free(phb->host); 231 g_free(phb); 232 return FALSE; 226 return phb_close(phb); 233 227 } 234 228 sock_make_blocking(source); … … 237 231 phb->host, phb->port); 238 232 if (send(source, cmd, strlen(cmd), 0) < 0) { 239 close(source); 240 phb->func(phb->data, -1, B_EV_IO_READ); 241 g_free(phb->host); 242 g_free(phb); 243 return FALSE; 233 return phb_close(phb); 244 234 } 245 235 … … 252 242 g_free(t2); 253 243 if (send(source, cmd, strlen(cmd), 0) < 0) { 254 close(source); 255 phb->func(phb->data, -1, B_EV_IO_READ); 256 g_free(phb->host); 257 g_free(phb); 258 return FALSE; 244 return phb_close(phb); 259 245 } 260 246 } … … 262 248 g_snprintf(cmd, sizeof(cmd), "\r\n"); 263 249 if (send(source, cmd, strlen(cmd), 0) < 0) { 264 close(source); 265 phb->func(phb->data, -1, B_EV_IO_READ); 266 g_free(phb->host); 267 g_free(phb); 268 return FALSE; 250 return phb_close(phb); 269 251 } 270 252 … … 302 284 } 303 285 304 close(source); 305 phb->func(phb->data, -1, B_EV_IO_READ); 306 g_free(phb->host); 307 g_free(phb); 308 309 return FALSE; 286 return phb_close(phb); 310 287 } 311 288 … … 323 300 len = sizeof(error); 324 301 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 325 close(source); 326 phb->func(phb->data, -1, B_EV_IO_READ); 327 g_free(phb->host); 328 g_free(phb); 329 return FALSE; 302 return phb_close(phb); 330 303 } 331 304 sock_make_blocking(source); … … 333 306 /* XXX does socks4 not support host name lookups by the proxy? */ 334 307 if (!(hp = gethostbyname(phb->host))) { 335 close(source); 336 phb->func(phb->data, -1, B_EV_IO_READ); 337 g_free(phb->host); 338 g_free(phb); 339 return FALSE; 308 return phb_close(phb); 340 309 } 341 310 … … 350 319 packet[8] = 0; 351 320 if (write(source, packet, 9) != 9) { 352 close(source); 353 phb->func(phb->data, -1, B_EV_IO_READ); 354 g_free(phb->host); 355 g_free(phb); 356 return FALSE; 321 return phb_close(phb); 357 322 } 358 323 … … 383 348 384 349 if (read(source, buf, 10) < 10) { 385 close(source); 386 phb->func(phb->data, -1, B_EV_IO_READ); 387 g_free(phb->host); 388 g_free(phb); 389 return FALSE; 350 return phb_close(phb); 390 351 } 391 352 if ((buf[0] != 0x05) || (buf[1] != 0x00)) { 392 close(source); 393 phb->func(phb->data, -1, B_EV_IO_READ); 394 g_free(phb->host); 395 g_free(phb); 396 return FALSE; 353 return phb_close(phb); 397 354 } 398 355 … … 420 377 421 378 if (write(source, buf, (5 + strlen(phb->host) + 2)) < (5 + strlen(phb->host) + 2)) { 422 close(source); 423 phb->func(phb->data, -1, B_EV_IO_READ); 424 g_free(phb->host); 425 g_free(phb); 379 phb_close(phb); 426 380 return; 427 381 } … … 438 392 439 393 if (read(source, buf, 2) < 2) { 440 close(source); 441 phb->func(phb->data, -1, B_EV_IO_READ); 442 g_free(phb->host); 443 g_free(phb); 444 return FALSE; 394 return phb_close(phb); 445 395 } 446 396 447 397 if ((buf[0] != 0x01) || (buf[1] != 0x00)) { 448 close(source); 449 phb->func(phb->data, -1, B_EV_IO_READ); 450 g_free(phb->host); 451 g_free(phb); 452 return FALSE; 398 return phb_close(phb); 453 399 } 454 400 … … 466 412 467 413 if (read(source, buf, 2) < 2) { 468 close(source); 469 phb->func(phb->data, -1, B_EV_IO_READ); 470 g_free(phb->host); 471 g_free(phb); 472 return FALSE; 414 return phb_close(phb); 473 415 } 474 416 475 417 if ((buf[0] != 0x05) || (buf[1] == 0xff)) { 476 close(source); 477 phb->func(phb->data, -1, B_EV_IO_READ); 478 g_free(phb->host); 479 g_free(phb); 480 return FALSE; 418 return phb_close(phb); 481 419 } 482 420 … … 489 427 memcpy(buf + 2 + i + 1, proxypass, j); 490 428 if (write(source, buf, 3 + i + j) < 3 + i + j) { 491 close(source); 492 phb->func(phb->data, -1, B_EV_IO_READ); 493 g_free(phb->host); 494 g_free(phb); 495 return FALSE; 429 return phb_close(phb); 496 430 } 497 431 … … 517 451 len = sizeof(error); 518 452 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 519 close(source); 520 phb->func(phb->data, -1, B_EV_IO_READ); 521 g_free(phb->host); 522 g_free(phb); 523 return FALSE; 453 return phb_close(phb); 524 454 } 525 455 sock_make_blocking(source); … … 539 469 540 470 if (write(source, buf, i) < i) { 541 close(source); 542 phb->func(phb->data, -1, B_EV_IO_READ); 543 g_free(phb->host); 544 g_free(phb); 545 return FALSE; 471 return phb_close(phb); 546 472 } 547 473 -
lib/ssl_gnutls.c
r531eabd rb1dc403 124 124 125 125 if (conn->fd < 0) { 126 g_free(conn->hostname); 126 127 g_free(conn); 127 128 return NULL; … … 314 315 if (source == -1) { 315 316 conn->func(conn->data, 0, NULL, cond); 317 g_free(conn->hostname); 316 318 g_free(conn); 317 319 return FALSE; … … 355 357 conn->func(conn->data, 0, NULL, cond); 356 358 357 gnutls_deinit(conn->session); 358 closesocket(conn->fd); 359 360 g_free(conn); 359 ssl_disconnect(conn); 361 360 } 362 361 } else { … … 364 363 conn->func(conn->data, stver, NULL, cond); 365 364 366 gnutls_deinit(conn->session); 367 closesocket(conn->fd); 368 369 g_free(conn); 365 ssl_disconnect(conn); 370 366 } else { 371 367 /* For now we can't handle non-blocking perfectly everywhere... */
Note: See TracChangeset
for help on using the changeset viewer.