Changeset 8b91a1f for protocols/twitter


Ignore:
Timestamp:
2015-03-10T07:27:25Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
7320610
Parents:
e6f47fb
git-author:
dequis <dx@…> (06-03-15 08:27:06)
git-committer:
dequis <dx@…> (10-03-15 07:27:25)
Message:

twitter: Fix twitter_parse_id to accept 00 as a valid tweet

Also fix the endptr condition which was backwards and resulted in every
tweet id getting rejected, but you didn't see that one, this commit
really is about the tweet id 00 which is the most important tweet id.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    re6f47fb r8b91a1f  
    852852}
    853853
    854 /* Parses a decimal or hex tweet ID, handling errors by returning 0 */
    855 static guint64 twitter_parse_id(char *string, int base)
     854/* Parses a decimal or hex tweet ID, returns TRUE on success */
     855static gboolean twitter_parse_id(char *string, int base, guint64 *id)
    856856{
    857857        guint64 parsed;
     
    860860        errno = 0;
    861861        parsed = g_ascii_strtoull(string, &endptr, base);
    862         if (errno || endptr == string || *endptr == '\0') {
    863                 return 0;
    864         }
    865         return parsed;
     862        if (errno || endptr == string || *endptr != '\0') {
     863                return FALSE;
     864        }
     865        *id = parsed;
     866        return TRUE;
    866867}
    867868
     
    893894                        arg++;
    894895                }
    895                 if ((id = twitter_parse_id(arg, 16)) && id < TWITTER_LOG_LENGTH) {
     896                if (twitter_parse_id(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {
    896897                        bu = td->log[id].bu;
    897898                        id = td->log[id].id;
     
    900901                                bu = NULL;
    901902                        }
    902                 } else if ((id = twitter_parse_id(arg, 10))) {
     903                } else if (twitter_parse_id(arg, 10, &id)) {
    903904                        /* Allow normal tweet IDs as well; not a very useful
    904905                           feature but it's always been there. Just ignore
Note: See TracChangeset for help on using the changeset viewer.