Changeset: db2ea56dad86 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=db2ea56dad86
Modified Files:
        sql/backends/monet5/sql_user.c
Branch: Jul2012
Log Message:

Free temporary storage.
Found by coverity.


diffs (76 lines):

diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c
--- a/sql/backends/monet5/sql_user.c
+++ b/sql/backends/monet5/sql_user.c
@@ -114,13 +114,11 @@ monet5_create_user(ptr _mvc, str user, s
                pwd = passwd;
        }
        /* add the user to the M5 authorisation administration */
-       if ((ret = AUTHaddUser(&uid, &c, &user, &pwd)) != MAL_SUCCEED) {
-               if (!enc)
-                       free(pwd);
-               return ret;
-       }
+       ret = AUTHaddUser(&uid, &c, &user, &pwd);
        if (!enc)
                free(pwd);
+       if (ret != MAL_SUCCEED)
+               return ret;
 
        user_id = store_next_oid();
        db_user_info = find_sql_table(s, "db_user_info");
@@ -272,6 +270,7 @@ monet5_alter_user(ptr _mvc, str user, st
                        if (oldpasswd != NULL) {
                                opwd = mcrypt_BackendSum(oldpasswd, 
strlen(oldpasswd));
                                if (opwd == NULL) {
+                                       free(pwd);
                                        (void)sql_error(m, 02, "ALTER USER: 
crypt backend hash not found");
                                        return FALSE;
                                }
@@ -281,7 +280,12 @@ monet5_alter_user(ptr _mvc, str user, st
                        opwd = oldpasswd;
                }
                if (user == NULL) {
-                       if ((err = AUTHchangePassword(&c, &opwd, &pwd)) != 
MAL_SUCCEED) {
+                       err = AUTHchangePassword(&c, &opwd, &pwd);
+                       if (!enc) {
+                               free(pwd);
+                               free(opwd);
+                       }
+                       if (err != MAL_SUCCEED) {
                                (void)sql_error(m, 02, "ALTER USER: %s", 
getExceptionMessage(err));
                                GDKfree(err);
                                return(FALSE);
@@ -289,19 +293,32 @@ monet5_alter_user(ptr _mvc, str user, st
                } else {
                        str username = NULL;
                        if ((err = AUTHresolveUser(&username, &c->user)) != 
MAL_SUCCEED) {
+                               if (!enc) {
+                                       free(pwd);
+                                       free(opwd);
+                               }
                                (void)sql_error(m, 02, "ALTER USER: %s", 
getExceptionMessage(err));
                                GDKfree(err);
                                return(FALSE);
                        }
                        if (strcmp(username, user) == 0) {
                                /* avoid message about changePassword (from MAL 
level) */
+                               if (!enc) {
+                                       free(pwd);
+                                       free(opwd);
+                               }
                                (void)sql_error(m, 02, "ALTER USER: "
                                                "use 'ALTER USER SET [ 
ENCRYPTED ] PASSWORD xxx "
                                                "USING OLD PASSWORD yyy' "
                                                "when changing your own 
password");
                                return(FALSE);
                        }
-                       if ((err = AUTHsetPassword(&c, &user, &pwd)) != 
MAL_SUCCEED) {
+                       err = AUTHsetPassword(&c, &user, &pwd);
+                       if (!enc) {
+                               free(pwd);
+                               free(opwd);
+                       }
+                       if (err != MAL_SUCCEED) {
                                (void)sql_error(m, 02, "ALTER USER: %s", 
getExceptionMessage(err));
                                GDKfree(err);
                                return(FALSE);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to