Changeset a880e34 for lib


Ignore:
Timestamp:
2015-02-28T20:40:07Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
a6b00fc
Parents:
8eb2e84
git-author:
dequis <dx@…> (28-02-15 19:40:16)
git-committer:
dequis <dx@…> (28-02-15 20:40:07)
Message:

Refactor oauth_params_del to fix use-after-free that i introduced

Yeah ok that was dumb.

This is essentially just using a 'data' variable instead of 'l->data',
but i went ahead and cleaned up the function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/oauth.c

    r8eb2e84 ra880e34  
    9696{
    9797        int key_len = strlen(key);
    98         GSList *l, *n;
    99 
    100         if (params == NULL) {
     98        GSList *l;
     99
     100        if (!params) {
    101101                return;
    102102        }
    103103
    104         for (l = *params; l; l = n) {
    105                 n = l->next;
    106 
    107                 if (strncmp((char *) l->data, key, key_len) == 0 &&
    108                     ((char *) l->data)[key_len] == '=') {
    109                         *params = g_slist_remove(*params, l->data);
    110                         g_free(l->data);
     104        for (l = *params; l; l = l->next) {
     105                char *data = l->data;
     106
     107                if (strncmp(data, key, key_len) == 0 && data[key_len] == '=') {
     108                        *params = g_slist_remove(*params, data);
     109                        g_free(data);
    111110                }
    112111        }
Note: See TracChangeset for help on using the changeset viewer.