]> diplodocus.org Git - nmh/blobdiff - sbr/credentials.c
Fix invalid pointer arithmetic.
[nmh] / sbr / credentials.c
index d8e4d2e4c8563045acd2855438b6fda9585912d4..b610b2b9810306dd9060c33125be4fec6c2547a8 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* credentials.c -- wrap configurable access to .netrc or similar files.
+ *
  * This code is Copyright (c) 2013, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
@@ -7,6 +8,7 @@
 #include <h/mh.h>
 #include <h/utils.h>
 #include <h/mts.h>
+#include "m_maildir.h"
 
 struct nmh_creds {
     char *host;                /* Hostname corresponding to credentials */
@@ -15,7 +17,7 @@ struct nmh_creds {
 };
 
 void
-init_credentials_file () {
+init_credentials_file(void) {
     if (credentials_file == NULL) {
         char *cred_style = context_find ("credentials");
 
@@ -28,7 +30,8 @@ init_credentials_file () {
             struct stat st;
             char *filename = strchr(cred_style, ':') + 1;
 
-            while (*filename && isspace ((unsigned char) *filename)) ++filename;
+            while (isspace((unsigned char)*filename))
+                filename++;
 
             if (*filename == '/') {
                 credentials_file = filename;
@@ -38,7 +41,7 @@ init_credentials_file () {
                     credentials_file =
                         concat (mypath ? mypath : ".", "/", filename, NULL);
                     if (stat (credentials_file, &st) != OK) {
-                        admonish (NULL, "unable to find credentials file %s",
+                        inform("unable to find credentials file %s, continuing...",
                                   filename);
                     }
                 }
@@ -79,7 +82,7 @@ nmh_get_credentials (const char *host, const char *user)
          */
         creds->user = user == NULL ? NULL : mh_xstrdup(user);
     } else {
-        admonish (NULL, "unknown credentials style %s", cred_style);
+        inform("unknown credentials style %s, continuing...", cred_style);
         return NULL;
     }
 
@@ -125,8 +128,8 @@ nmh_cred_get_password(nmh_creds_t creds)
 void
 nmh_credentials_free(nmh_creds_t creds)
 {
-    mh_xfree(creds->host);
-    mh_xfree(creds->user);
+    free(creds->host);
+    free(creds->user);
 
     if (creds->pass) {
        memset(creds->pass, 0, strlen(creds->pass));