From e26f01c28f5d91a9cc6dbca8af49b6bbc526ef8e Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Wed, 9 Mar 2011 23:11:02 +0200 Subject: Bugfixes. * modules/guile/Makefile.am (BUILT_SOURCES): Don't list guile.c * modules/mailutils/mailutils.c (checksize): Rewrite as a wrapper over an auxiliary function, to avoid memory leaks on errors. Make sure res->auth always has a meaningful value. * NEWS, configure.ac: version 1.1.90 --- NEWS | 5 +++- configure.ac | 2 +- modules/guile/Makefile.am | 2 +- modules/mailutils/mailutils.c | 58 ++++++++++++++++++++++++++----------------- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/NEWS b/NEWS index 2a19d04..cadeb42 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,13 @@ -Smap NEWS -- history of user-visible changes. 2010-07-03 +Smap NEWS -- history of user-visible changes. 2011-03-09 Copyright (C) 2006, 2007, 2008, 2009, 2010 Sergey Poznyakoff See the end of file for copying conditions. Please send Smap bug reports to +Version 1.1.90, Git + + Version 1.1, 2010-07-03 * New configuration statements diff --git a/configure.ac b/configure.ac index 9ee1d18..3722c75 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.63) m4_define([SMAP_VERSION_MAJOR], 1) m4_define([SMAP_VERSION_MINOR], 1) -dnl m4_define([SMAP_VERSION_PATCH], 0) +m4_define([SMAP_VERSION_PATCH], 90) AC_INIT([smap], SMAP_VERSION_MAJOR.SMAP_VERSION_MINOR[]m4_ifdef([SMAP_VERSION_PATCH],.SMAP_VERSION_PATCH), [gray+smap@gnu.org.ua]) diff --git a/modules/guile/Makefile.am b/modules/guile/Makefile.am index be2f4f4..3b86e93 100644 --- a/modules/guile/Makefile.am +++ b/modules/guile/Makefile.am @@ -24,7 +24,7 @@ AM_LDFLAGS = -module -avoid-version -no-undefined INCLUDES = -I$(top_srcdir)/include @GUILE_INCLUDES@ SUFFIXES = -BUILT_SOURCES = guile.c +BUILT_SOURCES = EXTRA_DIST = guile.x getpw.scm DOT_X_FILES = guile.x CLEANFILES= diff --git a/modules/mailutils/mailutils.c b/modules/mailutils/mailutils.c index b838317..06a9933 100644 --- a/modules/mailutils/mailutils.c +++ b/modules/mailutils/mailutils.c @@ -226,27 +226,14 @@ switch_user_id(struct mu_auth_data *auth, int user) } static int -checksize(struct _mu_smap_db *mdb, smap_stream_t ostr, - const char *user, struct _mu_smap_result *res, - char **preply) +checksize_user(struct _mu_smap_db *mdb, smap_stream_t ostr, + struct _mu_smap_result *res, + char **preply) { - struct mu_auth_data *auth; + int status, rc = 0; + struct mu_auth_data *auth = res->auth; mu_mailbox_t mbox; - int status; - - *preply = NULL; - - auth = mu_get_auth_by_name(user); - res->auth = auth; - if (!auth) { - res->diag = "user not found"; - smap_debug(dbgid, 1, ("%s: user not found", user)); - return 0; - } - if (switch_user_id(auth, 1)) { - res->diag = "local system error"; - return 0; - } + status = mu_mailbox_create_default(&mbox, auth->mailbox); if (status) { res->diag = "local system error"; @@ -291,15 +278,40 @@ checksize(struct _mu_smap_db *mdb, smap_stream_t ostr, stat = mdb->positive_reply; res->diag = "QUOTAOK"; } - if (expand_reply_text(stat, res, preply)) - return 1; + rc = expand_reply_text(stat, res, preply); } - switch_user_id(auth, 0); mu_mailbox_close(mbox); } mu_mailbox_destroy(&mbox); + return rc; +} + +static int +checksize(struct _mu_smap_db *mdb, smap_stream_t ostr, + const char *user, struct _mu_smap_result *res, + char **preply) +{ + struct mu_auth_data *auth; + int status; + + *preply = NULL; + + auth = mu_get_auth_by_name(user); + if (!auth) { + res->diag = "user not found"; + smap_debug(dbgid, 1, ("%s: user not found", user)); + return 0; + } + if (switch_user_id(auth, 1)) { + res->diag = "local system error"; + return 0; + } + res->auth = auth; + status = checksize_user(mdb, ostr, res, preply); + switch_user_id(auth, 0); mu_auth_data_free(auth); - return 0; + res->auth = NULL; + return status; } static int -- cgit v1.2.1