commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-379-geb851fb


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-379-geb851fb
Date: Thu, 04 Aug 2011 13:17:29 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=eb851fbc9fec91c1bd095500d3e9b24829ee53cc

The branch, master has been updated
       via  eb851fbc9fec91c1bd095500d3e9b24829ee53cc (commit)
      from  6060ab1110b1a1c27c1f88e22581a50b3930bf4b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit eb851fbc9fec91c1bd095500d3e9b24829ee53cc
Author: Sergey Poznyakoff <address@hidden>
Date:   Thu Aug 4 16:13:21 2011 +0300

    Various bugfixes.
    
    * libmailutils/base/assoc.c (first): Set index to max value
    if tab is NULL to indicate immediate end of iteration.
    * libmu_auth/sql.c (mu_auth_sql_by_name)
    (mu_auth_sql_by_uid): Check the return from mu_sql_num_tuples.
    (mu_sql_getpass): Check the number of returned tuples.
    Return failure if returned a NULL password.
    * libmu_scm/mu_message.c (string_sloppy_member): Remove.
    (mu-message-get-header-fields): Use scm_member instead of
    string_sloppy_member.
    * sql/postgres.c (chop): Handle NULL argument.

-----------------------------------------------------------------------

Summary of changes:
 libmailutils/base/assoc.c |   10 ++++++--
 libmu_auth/sql.c          |   53 +++++++++++++++++++++++++++++++++++++++++---
 libmu_scm/mu_message.c    |   19 ++-------------
 sql/postgres.c            |    4 ++-
 4 files changed, 62 insertions(+), 24 deletions(-)

diff --git a/libmailutils/base/assoc.c b/libmailutils/base/assoc.c
index 5c1e213..2d21fa8 100644
--- a/libmailutils/base/assoc.c
+++ b/libmailutils/base/assoc.c
@@ -393,9 +393,13 @@ first (void *owner)
   unsigned i;
 
   if (assoc->tab)
-    for (i = 0; i < hash_max; i++)
-      if ((ASSOC_ELEM (assoc, i))->name)
-       break;
+    {
+      for (i = 0; i < hash_max; i++)
+        if ((ASSOC_ELEM (assoc, i))->name)
+         break;
+    }
+  else
+    i = hash_max;
   itr->index = i;
   return 0;
 }
diff --git a/libmu_auth/sql.c b/libmu_auth/sql.c
index ddf1e12..4bd2e55 100644
--- a/libmu_auth/sql.c
+++ b/libmu_auth/sql.c
@@ -392,7 +392,17 @@ mu_auth_sql_by_name (struct mu_auth_data **return_data,
       return MU_ERR_FAILURE;
     }
 
-  mu_sql_num_tuples (conn, &n);
+  status = mu_sql_num_tuples (conn, &n);
+  if (status)
+    {
+      mu_error (_("cannot get number of tuples: %s"),
+                (status == MU_ERR_SQL) ?  mu_sql_strerror (conn) :
+                                          mu_strerror (status));
+      mu_sql_release_result (conn);
+      mu_sql_connection_destroy (&conn);
+      return MU_ERR_FAILURE;
+    }
+  
   if (n == 0)
     rc = MU_ERR_AUTH_FAILURE;
   else
@@ -476,7 +486,16 @@ mu_auth_sql_by_uid (struct mu_auth_data **return_data,
       return MU_ERR_FAILURE;
     }
 
-  mu_sql_num_tuples (conn, &n);
+  status = mu_sql_num_tuples (conn, &n);
+  if (status)
+    {
+      mu_error (_("cannot get number of tuples: %s"),
+                (status == MU_ERR_SQL) ?  mu_sql_strerror (conn) :
+                                          mu_strerror (status));
+      mu_sql_release_result (conn);
+      mu_sql_connection_destroy (&conn);
+      return MU_ERR_FAILURE;
+    }
 
   if (n == 0)
     rc = MU_ERR_AUTH_FAILURE;
@@ -497,7 +516,8 @@ mu_sql_getpass (const char *username, char **passwd)
   char *query_str;
   int status;
   char *sql_pass;
-  
+  size_t nt;
+
   query_str = mu_sql_expand_query (mu_sql_module_config.getpass_query, 
username);
 
   if (!query_str)
@@ -540,7 +560,7 @@ mu_sql_getpass (const char *username, char **passwd)
       mu_sql_connection_destroy (&conn);
       return MU_ERR_FAILURE;
     }
-
+  
   status = mu_sql_store_result (conn);
 
   if (status)
@@ -552,6 +572,23 @@ mu_sql_getpass (const char *username, char **passwd)
       return MU_ERR_FAILURE;
     }
 
+  status = mu_sql_num_tuples (conn, &nt);
+  if (status)
+    {
+      mu_error (_("cannot get number of tuples: %s"),
+                (status == MU_ERR_SQL) ?  mu_sql_strerror (conn) :
+                                          mu_strerror (status));
+      mu_sql_release_result (conn);
+      mu_sql_connection_destroy (&conn);
+      return MU_ERR_FAILURE;
+    }
+  if (nt == 0)
+    {
+      mu_sql_release_result (conn);
+      mu_sql_connection_destroy (&conn);
+      return MU_ERR_FAILURE;
+    }
+
   status = mu_sql_get_column (conn, 0, 0, &sql_pass);
   if (status)
     {
@@ -563,6 +600,14 @@ mu_sql_getpass (const char *username, char **passwd)
       return MU_ERR_FAILURE;
     }
 
+  if (!sql_pass)
+    {
+      mu_error (_("SQL returned NULL password"));
+      mu_sql_release_result (conn);
+      mu_sql_connection_destroy (&conn);
+      return MU_ERR_FAILURE;
+    }
+
   *passwd = strdup (sql_pass);
 
   mu_sql_disconnect (conn);
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index 4a99a8e..4ee603e 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -495,20 +495,6 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header, 
"mu-message-get-header", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-static int
-string_sloppy_member (SCM lst, char *name)
-{
-  for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
-    {
-      SCM car = SCM_CAR (lst);
-      if (scm_is_string (car)
-         && mu_c_strncasecmp (scm_i_string_chars (car), name,
-                              scm_i_string_length (car)) == 0)
-       return 1;
-    }
-  return 0;
-}
-
 SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, 
"mu-message-get-header-fields", 1, 1, 0,
                   (SCM mesg, SCM headers),
 "Returns list of headers in the message @var{mesg}. optional argument\n" 
@@ -547,8 +533,9 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, 
"mu-message-get-header-fiel
        mu_scm_error (FUNC_NAME, status,
                      "Cannot get header field ~A, message ~A",
                      scm_list_2 (scm_from_size_t (i), mesg));
-      
-      if (!scm_is_null (headers) && string_sloppy_member (headers, name) == 0)
+
+      if (!scm_is_null (headers) &&
+         scm_member (headers, scm_from_locale_string (name)) == SCM_BOOL_F)
        continue;
       status = mu_header_aget_field_value (hdr, i, &value);
       if (status)
diff --git a/sql/postgres.c b/sql/postgres.c
index dda3434..bf48bc3 100644
--- a/sql/postgres.c
+++ b/sql/postgres.c
@@ -32,7 +32,9 @@ chop (char *str)
 {
   int len;
   
-  for (len = strlen(str); len > 0 && mu_isspace(str[len-1]); len--)
+  if (!str)
+    return NULL;
+  for (len = strlen (str); len > 0 && mu_isspace (str[len-1]); len--)
     ;
   str[len] = 0;
   return str;


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]