Merge branch 'master' into gregoa
authorgregor herrmann <gregoa@debian.org>
Fri, 4 Nov 2011 19:46:33 +0000 (20:46 +0100)
committergregor herrmann <gregoa@debian.org>
Fri, 4 Nov 2011 19:46:33 +0000 (20:46 +0100)
HACKING
bti.c
bti.xml
config.c

diff --git a/HACKING b/HACKING
index 19bd8c9..d8dea3d 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -1,7 +1,7 @@
 Patches are gladly accepted for bti code, please send them to
 greg@kroah.com, or you can use github to send a pull request.
 
-The code tree for smubatch is located at:
+The code tree for bti is located at:
        http://github.com/gregkh/bti
 and can be cloned using git from:
        git://github.com/gregkh/bti.git
diff --git a/bti.c b/bti.c
index db9cadc..8478345 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -100,8 +100,10 @@ static char *get_string(const char *name)
                exit(1);
        if (name != NULL)
                fprintf(stdout, "%s", name);
-       if (!fgets(string, 999, stdin))
+       if (!fgets(string, 999, stdin)) {
+               free(string);
                return NULL;
+       }
        temp = strchr(string, '\n');
        if (temp)
                *temp = '\0';
@@ -256,9 +258,9 @@ const char identica_name[] = "identi.ca";
 static const char twitter_request_token_uri[]  = "http://twitter.com/oauth/request_token";
 static const char twitter_access_token_uri[]   = "http://twitter.com/oauth/access_token";
 static const char twitter_authorize_uri[]      = "http://twitter.com/oauth/authorize?oauth_token=";
-static const char identica_request_token_uri[] = "http://identi.ca/api/oauth/request_token?oauth_callback=oob";
-static const char identica_access_token_uri[]  = "http://identi.ca/api/oauth/access_token";
-static const char identica_authorize_uri[]     = "http://identi.ca/api/oauth/authorize?oauth_token=";
+static const char identica_request_token_uri[] = "https://identi.ca/api/oauth/request_token?oauth_callback=oob";
+static const char identica_access_token_uri[]  = "https://identi.ca/api/oauth/access_token";
+static const char identica_authorize_uri[]     = "https://identi.ca/api/oauth/authorize?oauth_token=";
 
 static const char user_uri[]     = "/user_timeline/";
 static const char update_uri[]   = "/update.xml";
@@ -555,8 +557,10 @@ static int send_request(struct session *session)
                curl_buf->session = session;
 
                curl = curl_init();
-               if (!curl)
+               if (!curl) {
+                       bti_curl_buffer_free(curl_buf);
                        return -EINVAL;
+               }
 
                if (!session->hosturl)
                        session->hosturl = strdup(twitter_host);
@@ -656,6 +660,10 @@ static int send_request(struct session *session)
                                if (res) {
                                        fprintf(stderr, "error(%d) trying to "
                                                "perform operation\n", res);
+                                       curl_easy_cleanup(curl);
+                                       if (session->action == ACTION_UPDATE)
+                                               curl_formfree(formpost);
+                                       bti_curl_buffer_free(curl_buf);
                                        return -EINVAL;
                                }
 
@@ -663,19 +671,32 @@ static int send_request(struct session *session)
                                                    curl_buf->length,
                                                    "response.xml", NULL,
                                                    XML_PARSE_NOERROR);
-                               if (doc == NULL)
+                               if (doc == NULL) {
+                                       curl_easy_cleanup(curl);
+                                       if (session->action == ACTION_UPDATE)
+                                               curl_formfree(formpost);
+                                       bti_curl_buffer_free(curl_buf);
                                        return -EINVAL;
+                               }
 
                                current = xmlDocGetRootElement(doc);
                                if (current == NULL) {
                                        fprintf(stderr, "empty document\n");
                                        xmlFreeDoc(doc);
+                                       curl_easy_cleanup(curl);
+                                       if (session->action == ACTION_UPDATE)
+                                               curl_formfree(formpost);
+                                       bti_curl_buffer_free(curl_buf);
                                        return -EINVAL;
                                }
 
                                if (xmlStrcmp(current->name, (const xmlChar *)"status")) {
                                        fprintf(stderr, "unexpected document type\n");
                                        xmlFreeDoc(doc);
+                                       curl_easy_cleanup(curl);
+                                       if (session->action == ACTION_UPDATE)
+                                               curl_formfree(formpost);
+                                       bti_curl_buffer_free(curl_buf);
                                        return -EINVAL;
                                }
 
@@ -835,8 +856,10 @@ static char *get_string_from_stdin(void)
        if (!string)
                return NULL;
 
-       if (!fgets(string, 999, stdin))
+       if (!fgets(string, 999, stdin)) {
+               free(string);
                return NULL;
+       }
        temp = strchr(string, '\n');
        if (temp)
                *temp = '\0';
diff --git a/bti.xml b/bti.xml
index dfd0718..58d05ae 100644 (file)
--- a/bti.xml
+++ b/bti.xml
@@ -1,4 +1,5 @@
 <?xml version='1.0'?>
+<?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
 
index e06f480..2b510b9 100644 (file)
--- a/config.c
+++ b/config.c
@@ -351,20 +351,21 @@ void bti_parse_configfile(struct session *session)
                 * marker if it occurs at the beginning of the line, or after
                 * whitespace
                 */
-               hashmarker = strchrnul(line, '#');
+               hashmarker = strchr(line, '#');
                if (line == hashmarker)
                        line[0] = '\0';
                else {
-                       while (hashmarker[0] != '\0') {
+                       while (hashmarker != NULL) {
                                --hashmarker;
-                               if (isblank(hashmarker[0]))
+                               if (isblank(hashmarker[0])) {
                                        hashmarker[0] = '\0';
-                               else {
+                                       break;
+                               } else {
                                        /*
                                         * false positive; '#' occured
                                         * within a string
                                         */
-                                       hashmarker = strchrnul(hashmarker+2, '#');
+                                       hashmarker = strchr(hashmarker+2, '#');
                                }
                        }
                }