Changeset b1dc403 for lib


Ignore:
Timestamp:
2015-05-04T21:58:50Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
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.
Message:

Catch up with master.

Location:
lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    r531eabd rb1dc403  
    719719                        }
    720720
    721                         /* Make sure we're still inside the string */
    722                         if (i >= len) {
    723                                 return(NULL);
    724                         }
    725 
    726721                        /* Copy the found data */
    727722                        return(g_strndup(ret, text + i - ret));
  • lib/oauth.c

    r531eabd rb1dc403  
    9898        GSList *l, *n;
    9999
    100         if (params == NULL) {
     100        if (!params) {
    101101                return;
    102102        }
     
    104104        for (l = *params; l; l = n) {
    105105                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);
    111111                }
    112112        }
  • lib/proxy.c

    r531eabd rb1dc403  
    6363static int proxy_connect_none(const char *host, unsigned short port_, struct PHB *phb);
    6464
    65 static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond)
     65static 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
     74static gboolean proxy_connected(gpointer data, gint source, b_input_condition cond)
    6675{
    6776        struct PHB *phb = data;
     
    8089                                dup2(new_fd, source);
    8190                                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);
    8392                                return FALSE;
    8493                        }
    8594                }
    86                 freeaddrinfo(phb->gai);
    8795                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
    98102        freeaddrinfo(phb->gai);
    99         sock_make_blocking(source);
    100103        b_event_remove(phb->inpa);
    101104        phb->inpa = 0;
     
    160163                        continue;
    161164                } 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);
    163166                        phb->fd = fd;
    164167
     
    206209        }
    207210
    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);
    214212}
    215213
     
    226224        len = sizeof(error);
    227225        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);
    233227        }
    234228        sock_make_blocking(source);
     
    237231                   phb->host, phb->port);
    238232        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);
    244234        }
    245235
     
    252242                g_free(t2);
    253243                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);
    259245                }
    260246        }
     
    262248        g_snprintf(cmd, sizeof(cmd), "\r\n");
    263249        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);
    269251        }
    270252
     
    302284        }
    303285
    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);
    310287}
    311288
     
    323300        len = sizeof(error);
    324301        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);
    330303        }
    331304        sock_make_blocking(source);
     
    333306        /* XXX does socks4 not support host name lookups by the proxy? */
    334307        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);
    340309        }
    341310
     
    350319        packet[8] = 0;
    351320        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);
    357322        }
    358323
     
    383348
    384349        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);
    390351        }
    391352        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);
    397354        }
    398355
     
    420377
    421378        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);
    426380                return;
    427381        }
     
    438392
    439393        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);
    445395        }
    446396
    447397        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);
    453399        }
    454400
     
    466412
    467413        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);
    473415        }
    474416
    475417        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);
    481419        }
    482420
     
    489427                memcpy(buf + 2 + i + 1, proxypass, j);
    490428                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);
    496430                }
    497431
     
    517451        len = sizeof(error);
    518452        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);
    524454        }
    525455        sock_make_blocking(source);
     
    539469
    540470        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);
    546472        }
    547473
  • lib/ssl_gnutls.c

    r531eabd rb1dc403  
    124124
    125125        if (conn->fd < 0) {
     126                g_free(conn->hostname);
    126127                g_free(conn);
    127128                return NULL;
     
    314315        if (source == -1) {
    315316                conn->func(conn->data, 0, NULL, cond);
     317                g_free(conn->hostname);
    316318                g_free(conn);
    317319                return FALSE;
     
    355357                        conn->func(conn->data, 0, NULL, cond);
    356358
    357                         gnutls_deinit(conn->session);
    358                         closesocket(conn->fd);
    359 
    360                         g_free(conn);
     359                        ssl_disconnect(conn);
    361360                }
    362361        } else {
     
    364363                        conn->func(conn->data, stver, NULL, cond);
    365364
    366                         gnutls_deinit(conn->session);
    367                         closesocket(conn->fd);
    368 
    369                         g_free(conn);
     365                        ssl_disconnect(conn);
    370366                } else {
    371367                        /* For now we can't handle non-blocking perfectly everywhere... */
Note: See TracChangeset for help on using the changeset viewer.