Make sure respbuffer is not null before manipulating it. If it is null,
authorJP Rosevear <jpr@helixcode.com>
Mon, 21 Aug 2000 19:56:14 +0000 (19:56 +0000)
committerJP Rosevear <jpr@src.gnome.org>
Mon, 21 Aug 2000 19:56:14 +0000 (19:56 +0000)
2000-08-21  JP Rosevear  <jpr@helixcode.com>

* providers/nntp/camel-nntp-store.c (camel_nntp_command):
Make sure respbuffer is not null before manipulating it.
If it is null, return CAMEL_NNTP_FAIL and a decent error
message.

camel/ChangeLog
camel/providers/nntp/camel-nntp-store.c

index 09bfcac..d072116 100644 (file)
@@ -1,3 +1,10 @@
+2000-08-21  JP Rosevear  <jpr@helixcode.com>
+
+       * providers/nntp/camel-nntp-store.c (camel_nntp_command): 
+       Make sure respbuffer is not null before manipulating it.
+       If it is null, return CAMEL_NNTP_FAIL and a decent error
+       message.
+       
 2000-08-18  Peter Williams  <peterw@helixcode.com>
 
        * camel-internet-address.c (internet_encode): If the name is "" we
index 45b1fde..7495201 100644 (file)
@@ -292,22 +292,29 @@ camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...)
 
        /* Read the response */
        respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream));
-       resp_code = atoi (respbuf);
 
+       if (!respbuf) {
+               if (ret)
+                       *ret = g_strdup (g_strerror (errno));
+               return CAMEL_NNTP_FAIL;
+       }
+       
+       resp_code = atoi (respbuf);
+               
        if (resp_code < 400)
                status = CAMEL_NNTP_OK;
        else if (resp_code < 500)
                status = CAMEL_NNTP_ERR;
        else
                status = CAMEL_NNTP_FAIL;
-
+       
        if (ret) {
                *ret = strchr (respbuf, ' ');
                if (*ret)
                        *ret = g_strdup (*ret + 1);
        }
        g_free (respbuf);
-
+       
        return status;
 }