fixes (asprintf) from 2.2
authorSimo Sorce <idra@samba.org>
Sat, 19 Jan 2002 17:29:32 +0000 (17:29 +0000)
committerSimo Sorce <idra@samba.org>
Sat, 19 Jan 2002 17:29:32 +0000 (17:29 +0000)
source/client/client.c
source/lib/snprintf.c
source/nsswitch/winbindd_cm.c
source/passdb/pdb_tdb.c
source/rpcclient/cmd_spoolss.c

index f1059f8ee1ffd8a227fda1b1b8b213623500dfb0..eb9750299b76c3ce0726df47c20f60eb324a56d8 100644 (file)
@@ -1343,7 +1343,7 @@ static int cmd_mput(void)
                                /* if (!recurse) continue; */
                                
                                SAFE_FREE(quest);
-                               asprintf(&quest, "Put directory %s? ", lname);
+                               if (asprintf(&quest, "Put directory %s? ", lname) < 0) break;
                                if (prompt && !yesno(quest)) { /* No */
                                        /* Skip the directory */
                                        lname[strlen(lname)-1] = '/';
@@ -1351,7 +1351,7 @@ static int cmd_mput(void)
                                                break;              
                                } else { /* Yes */
                                        SAFE_FREE(rname);
-                                       asprintf(&rname, "%s%s", cur_dir, lname);
+                                       if(asprintf(&rname, "%s%s", cur_dir, lname) < 0) break;
                                        dos_format(rname);
                                        if (!cli_chkpath(cli, rname) && 
                                            !do_mkdir(rname)) {
@@ -1365,13 +1365,13 @@ static int cmd_mput(void)
                                continue;
                        } else {
                                SAFE_FREE(quest);
-                               asprintf(&quest,"Put file %s? ", lname);
+                               if (asprintf(&quest,"Put file %s? ", lname) < 0) break;
                                if (prompt && !yesno(quest)) /* No */
                                        continue;
                                
                                /* Yes */
                                SAFE_FREE(rname);
-                               asprintf(&rname, "%s%s", cur_dir, lname);
+                               if (asprintf(&rname, "%s%s", cur_dir, lname) < 0) break;
                        }
 
                        dos_format(rname);
index 88eea2824befdc5c3e83bc2faaec8bab85576326..9a9dcdbae1e60db6fa23f4fba6a1debb469b2610 100644 (file)
@@ -803,6 +803,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
        va_list ap;
        int ret;
        
+       *ptr = NULL;
        va_start(ap, format);
        ret = vasprintf(ptr, format, ap);
        va_end(ap);
index 013289ed136ebffeede81f34ba145f8612ff4c2d..5d6c758e10743f672812b82e68af509bf72803d5 100644 (file)
@@ -712,10 +712,12 @@ static void dump_conn_list(void)
 
                /* Display pipe info */
                
-               asprintf(&msg, "\t%-15s %-15s %-16s", con->domain, con->controller, con->pipe_name);
-               
-               DEBUG(0, ("%s\n", msg));
-               free(msg);
+               if (asprintf(&msg, "\t%-15s %-15s %-16s", con->domain, con->controller, con->pipe_name) < 0) {
+                       DEBUG(0, ("Error: not enough memory!\n"));
+               } else {
+                       DEBUG(0, ("%s\n", msg));
+                       SAFE_FREE(msg);
+               }
        }
 }
 
index 1f234edc9336b8ecbbf7a629b285171405b36be0..b33e684c7a17af3d22bd5ba05c01922072e795c0 100644 (file)
@@ -488,13 +488,13 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user)
        sam_user = pdb_get_username(user);
        pstrcpy(sam_subst, pdb_get_logon_script(user));
        standard_sub_advanced(-1, sam_user, "", gid, sam_user, sam_subst);
-       pdb_set_logon_script(user, sam_subst, True);
+       if (!pdb_set_logon_script(user, sam_subst, True)) return False;
        pstrcpy(sam_subst, pdb_get_profile_path(user));
        standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
-       pdb_set_profile_path(user, sam_subst, True);
+       if (!pdb_set_profile_path(user, sam_subst, True)) return False;
        pstrcpy(sam_subst, pdb_get_homedir(user));
        standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
-       pdb_set_homedir(user, sam_subst, True);
+       if (!pdb_set_homedir(user, sam_subst, True)) return False;
 
        /* increment to next in line */
        global_tdb_ent.key = tdb_nextkey(global_tdb_ent.passwd_tdb, global_tdb_ent.key);
@@ -578,13 +578,13 @@ BOOL pdb_getsampwnam (SAM_ACCOUNT *user, const char *sname)
                sam_user = pdb_get_username(user);
                pstrcpy(sam_subst, pdb_get_logon_script(user));
                standard_sub_advanced(-1, sam_user, "", gid, sam_user, sam_subst);
-               pdb_set_logon_script(user, sam_subst, True);
+               if (!pdb_set_logon_script(user, sam_subst, True)) return False;
                pstrcpy(sam_subst, pdb_get_profile_path(user));
                standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
-               pdb_set_profile_path(user, sam_subst, True);
+               if (!pdb_set_profile_path(user, sam_subst, True)) return False;
                pstrcpy(sam_subst, pdb_get_homedir(user));
                standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
-               pdb_set_homedir(user, sam_subst, True);
+               if (!pdb_set_homedir(user, sam_subst, True)) return False;
        }
        else {
                DEBUG(0,("pdb_getsampwent: getpwnam(%s) return NULL.  User does not exist!\n", 
index ed656323440f0debbda849cc3840eea705ef0319..f0e6af9822c8ec21c8b1c50aeb2559c089465550 100644 (file)
@@ -1183,11 +1183,15 @@ static NTSTATUS cmd_spoolss_getprintprocdir(struct cli_state *cli,
                return NT_STATUS_OK;
         }
 
-       asprintf(&servername, "\\\\%s", cli->desthost);
+       if (asprintf(&servername, "\\\\%s", cli->desthost) < 0)
+               return NT_STATUS_NO_MEMORY;
        strupper(servername);
 
-       asprintf(&environment, "%s", (argc == 3) ? argv[2] : 
-                PRINTER_DRIVER_ARCHITECTURE);
+       if (asprintf(&environment, "%s", (argc == 3) ? argv[2] : 
+                                       PRINTER_DRIVER_ARCHITECTURE) < 0) {
+               SAFE_FREE(servername);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        result = cli_spoolss_getprintprocessordirectory(
                cli, mem_ctx, servername, environment, procdir);