* New upstream release:
authorgregor herrmann <gregoa@debian.org>
Tue, 22 Mar 2011 16:17:37 +0000 (16:17 -0000)
committergregor herrmann <gregoa@debian.org>
Tue, 22 Mar 2011 16:17:37 +0000 (16:17 -0000)
  - addresses "bti doesn't warn if the password is incorrect": check server
    replies in non-background mode, only in non-OAuth mode
    (partly solves #602502)

ChangeLog
RELEASE-NOTES
bti.c
config.c
configure
configure.ac
debian/changelog

index 550d2eb..384ed9f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Summary of changes from v030 to v031
+============================================
+
+Diego Elio Pettenò (1):
+      In non-background execution, check whether the server reports success.
+
+Greg Kroah-Hartman (2):
+      code formatting cleanups
+      config: fix possible access of non-allocated memory
+
+Michel Alexandre Salim (2):
+      Only treat # as a comment marker if it's at the beginning of line or is preceded by a whitespace character
+      Keep searching for '#' comment marker if previous occurence was a false positive
+
+
 Summary of changes from v029 to v030
 ============================================
 
index 10f1bc2..0416000 100644 (file)
@@ -1,3 +1,10 @@
+bti 031
+=============
+- Check for identi.ca server success or not in non-background mode
+  thanks to Flameeyes
+- Handle '#' in a password in the config file properly thanks to Michel
+  Alexandre Salim
+
 bti 030
 =============
 More minor bugfixes
diff --git a/bti.c b/bti.c
index 147d44b..881b826 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -324,7 +324,8 @@ static void parse_statuses(struct session *session,
                        }
 
                        if (user && text && created && id) {
-                               bti_output_line(session, user, id, created, text);
+                               bti_output_line(session, user, id,
+                                               created, text);
                                xmlFree(user);
                                xmlFree(text);
                                xmlFree(created);
@@ -445,7 +446,7 @@ static int request_access_token(struct session *session)
 {
        char *post_params = NULL;
        char *request_url = NULL;
-       char *reply       = NULL;
+       char *reply       = NULL;
        char *at_key      = NULL;
        char *at_secret   = NULL;
        char *verifier    = NULL;
@@ -573,8 +574,10 @@ static int send_request(struct session *session)
 
                        if (session->replyto)
                                curl_formadd(&formpost, &lastptr,
-                                            CURLFORM_COPYNAME, "in_reply_to_status_id",
-                                            CURLFORM_COPYCONTENTS, session->replyto,
+                                            CURLFORM_COPYNAME,
+                                            "in_reply_to_status_id",
+                                            CURLFORM_COPYCONTENTS,
+                                            session->replyto,
                                             CURLFORM_END);
 
                        curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
@@ -641,10 +644,37 @@ static int send_request(struct session *session)
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf);
                if (!session->dry_run) {
                        res = curl_easy_perform(curl);
-                       if (res && !session->background) {
-                               fprintf(stderr, "error(%d) trying to perform "
-                                               "operation\n", res);
-                               return -EINVAL;
+                       if (!session->background) {
+                               xmlDocPtr doc;
+                               xmlNodePtr current;
+
+                               if (res) {
+                                       fprintf(stderr, "error(%d) trying to "
+                                               "perform operation\n", res);
+                                       return -EINVAL;
+                               }
+
+                               doc = xmlReadMemory(curl_buf->data,
+                                                   curl_buf->length,
+                                                   "response.xml", NULL,
+                                                   XML_PARSE_NOERROR);
+                               if (doc == NULL)
+                                       return -EINVAL;
+
+                               current = xmlDocGetRootElement(doc);
+                               if (current == NULL) {
+                                       fprintf(stderr, "empty document\n");
+                                       xmlFreeDoc(doc);
+                                       return -EINVAL;
+                               }
+
+                               if (xmlStrcmp(current->name, (const xmlChar *)"status")) {
+                                       fprintf(stderr, "unexpected document type\n");
+                                       xmlFreeDoc(doc);
+                                       return -EINVAL;
+                               }
+
+                               xmlFreeDoc(doc);
                        }
                }
 
@@ -1220,7 +1250,7 @@ int main(int argc, char *argv[], char *envp[])
                                session->action = ACTION_PUBLIC;
                        else if (strcasecmp(optarg, "group") == 0)
                                session->action = ACTION_GROUP;
-                       else if (strcasecmp(optarg,"retweet") == 0)
+                       else if (strcasecmp(optarg, "retweet") == 0)
                                session->action = ACTION_RETWEET;
                        else
                                session->action = ACTION_UNKNOWN;
@@ -1314,7 +1344,10 @@ int main(int argc, char *argv[], char *envp[])
                if (!session->consumer_key || !session->consumer_secret) {
                        if (session->action == ACTION_USER ||
                                        session->action == ACTION_PUBLIC) {
-                               /* Some actions may still work without authentication */
+                               /*
+                                * Some actions may still work without
+                                * authentication
+                                */
                                session->guest = 1;
                        } else {
                                fprintf(stderr,
@@ -1370,7 +1403,7 @@ int main(int argc, char *argv[], char *envp[])
                        fprintf(stdout, "Status ID to retweet: ");
                        rtid = get_string_from_stdin();
                        session->retweet = zalloc(strlen(rtid) + 10);
-                       sprintf(session->retweet,"%s", rtid);
+                       sprintf(session->retweet, "%s", rtid);
                        free(rtid);
                }
 
index 346fed8..e06f480 100644 (file)
--- a/config.c
+++ b/config.c
@@ -327,6 +327,7 @@ void bti_parse_configfile(struct session *session)
        char *line = NULL;
        char *key = NULL;
        char *value = NULL;
+       char *hashmarker;
        size_t len = 0;
        ssize_t n;
        char *c;
@@ -344,8 +345,29 @@ void bti_parse_configfile(struct session *session)
                if (line[n - 1] == '\n')
                        line[n - 1] = '\0';
 
-               /* '#' is comment markers, like bash style */
-               *strchrnul(line, '#') = '\0';
+               /*
+                * '#' is comment markers, like bash style but it is a valid
+                * character in some fields, so only treat it as a comment
+                * marker if it occurs at the beginning of the line, or after
+                * whitespace
+                */
+               hashmarker = strchrnul(line, '#');
+               if (line == hashmarker)
+                       line[0] = '\0';
+               else {
+                       while (hashmarker[0] != '\0') {
+                               --hashmarker;
+                               if (isblank(hashmarker[0]))
+                                       hashmarker[0] = '\0';
+                               else {
+                                       /*
+                                        * false positive; '#' occured
+                                        * within a string
+                                        */
+                                       hashmarker = strchrnul(hashmarker+2, '#');
+                               }
+                       }
+               }
                c = line;
                while (isspace(*c))
                        c++;
index 19546d8..3d203ac 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for bti 030.
+# Generated by GNU Autoconf 2.68 for bti 031.
 #
 # Report bugs to <greg@kroah.com>.
 #
@@ -559,8 +559,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='bti'
 PACKAGE_TARNAME='bti'
-PACKAGE_VERSION='030'
-PACKAGE_STRING='bti 030'
+PACKAGE_VERSION='031'
+PACKAGE_STRING='bti 031'
 PACKAGE_BUGREPORT='greg@kroah.com'
 PACKAGE_URL=''
 
@@ -1226,7 +1226,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures bti 030 to adapt to many kinds of systems.
+\`configure' configures bti 031 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1292,7 +1292,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of bti 030:";;
+     short | recursive ) echo "Configuration of bti 031:";;
    esac
   cat <<\_ACEOF
 
@@ -1399,7 +1399,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-bti configure 030
+bti configure 031
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1500,7 +1500,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by bti $as_me 030, which was
+It was created by bti $as_me 031, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2317,7 +2317,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE=bti
- VERSION=030
+ VERSION=031
 
 
 cat >>confdefs.h <<_ACEOF
@@ -4503,7 +4503,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by bti $as_me 030, which was
+This file was extended by bti $as_me 031, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4560,7 +4560,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-bti config.status 030
+bti config.status 031
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
index 39643d4..8dc3071 100644 (file)
@@ -1,7 +1,7 @@
-AC_INIT([bti], [030], [greg@kroah.com])
+AC_INIT([bti], [031], [greg@kroah.com])
 AC_PREREQ(2.60)
 
-AM_INIT_AUTOMAKE(bti, 030)
+AM_INIT_AUTOMAKE(bti, 031)
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
index 5b22a7f..3f9c791 100644 (file)
@@ -1,3 +1,12 @@
+bti (031-1) UNRELEASED; urgency=low
+
+  * New upstream release:
+    - addresses "bti doesn't warn if the password is incorrect": check server
+      replies in non-background mode, only in non-OAuth mode
+      (partly solves #602502)
+
+ -- gregor herrmann <gregoa@debian.org>  Tue, 22 Mar 2011 17:14:01 +0100
+
 bti (030-1) unstable; urgency=low
 
   * New upstream release.