Fix more ‘asprintf’, declared with attribute warn_unused_result.
authorJeremy Allison <jeremy@jeremy-desktop.(none)>
Tue, 23 Dec 2008 18:42:25 +0000 (10:42 -0800)
committerJeremy Allison <jeremy@jeremy-desktop.(none)>
Tue, 23 Dec 2008 18:42:25 +0000 (10:42 -0800)
Jeremy.

source3/passdb/pdb_interface.c
source3/passdb/pdb_ldap.c

index 5a79f09db063e9b667673730c53c1db173d0c685..b13644bac369a7986cde4a908587c2fe05bcd7b3 100644 (file)
@@ -179,20 +179,26 @@ static struct pdb_methods *pdb_get_methods_reload( bool reload )
                pdb->free_private_data( &(pdb->private_data) );
                if ( !NT_STATUS_IS_OK( make_pdb_method_name( &pdb, lp_passdb_backend() ) ) ) {
                        char *msg = NULL;
-                       asprintf(&msg, "pdb_get_methods_reload: "
-                               "failed to get pdb methods for backend %s\n",
-                               lp_passdb_backend());
-                       smb_panic(msg);
+                       if (asprintf(&msg, "pdb_get_methods_reload: "
+                                       "failed to get pdb methods for backend %s\n",
+                                       lp_passdb_backend()) > 0) {
+                               smb_panic(msg);
+                       } else {
+                               smb_panic("pdb_get_methods_reload");
+                       }
                }
        }
 
        if ( !pdb ) {
                if ( !NT_STATUS_IS_OK( make_pdb_method_name( &pdb, lp_passdb_backend() ) ) ) {
                        char *msg = NULL;
-                       asprintf(&msg, "pdb_get_methods_reload: "
-                               "failed to get pdb methods for backend %s\n",
-                               lp_passdb_backend());
-                       smb_panic(msg);
+                       if (asprintf(&msg, "pdb_get_methods_reload: "
+                                       "failed to get pdb methods for backend %s\n",
+                                       lp_passdb_backend()) > 0) {
+                               smb_panic(msg);
+                       } else {
+                               smb_panic("pdb_get_methods_reload");
+                       }
                }
        }
 
index 95e9a01ba317c0c2e7df67a95412413fb4dc92dc..f031483ea1596eba50a844123535c02377896df2 100644 (file)
@@ -4184,9 +4184,10 @@ static char *get_ldap_filter(TALLOC_CTX *mem_ctx, const char *username)
        char *escaped = NULL;
        char *result = NULL;
 
-       asprintf(&filter, "(&%s(objectclass=%s))",
-                         "(uid=%u)", LDAP_OBJ_SAMBASAMACCOUNT);
-       if (filter == NULL) goto done;
+       if (asprintf(&filter, "(&%s(objectclass=%s))",
+                         "(uid=%u)", LDAP_OBJ_SAMBASAMACCOUNT) < 0) {
+               goto done;
+       }
 
        escaped = escape_ldap_string_alloc(username);
        if (escaped == NULL) goto done;