Fix some "ignoring asprintf result" warnings
authorVolker Lendecke <vl@samba.org>
Wed, 2 Apr 2008 13:54:49 +0000 (15:54 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 14 Apr 2008 11:13:46 +0000 (13:13 +0200)
source/smbd/lanman.c
source/smbd/process.c

index 18e6bf9f7b266f4926cdc7bd7f13b1f52402bee3..6fa4f9698d9611d13a070ce01bc9e5f4786f1c80 100644 (file)
@@ -1971,24 +1971,24 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid,
                return False;
        }
 
-       asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
-               lp_add_share_cmd(), get_dyn_CONFIGFILE(), sharename, pathname, comment);
+       if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
+                    lp_add_share_cmd(), get_dyn_CONFIGFILE(), sharename,
+                    pathname, comment) == -1) {
+               return false;
+       }
 
-       if (command) {
-               DEBUG(10,("api_RNetShareAdd: Running [%s]\n", command ));
+       DEBUG(10,("api_RNetShareAdd: Running [%s]\n", command ));
 
-               if ((res = smbrun(command, NULL)) != 0) {
-                       DEBUG(1,("api_RNetShareAdd: Running [%s] returned (%d)\n", command, res ));
-                       SAFE_FREE(command);
-                       res = ERRnoaccess;
-                       goto error_exit;
-               } else {
-                       SAFE_FREE(command);
-                       message_send_all(smbd_messaging_context(),
-                                        MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
-               }
+       if ((res = smbrun(command, NULL)) != 0) {
+               DEBUG(1,("api_RNetShareAdd: Running [%s] returned (%d)\n",
+                        command, res ));
+               SAFE_FREE(command);
+               res = ERRnoaccess;
+               goto error_exit;
        } else {
-               return False;
+               SAFE_FREE(command);
+               message_send_all(smbd_messaging_context(),
+                                MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
        }
 
        *rparam_len = 6;
index 88684315cc79a71666f08632b389e72f7a3b69a6..5946989ae75d721aa359cd11f005e4272a05cb6a 100644 (file)
@@ -1259,8 +1259,10 @@ void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
        if ((num_bytes > 0xffffff)
            || ((num_bytes + smb_size + num_words*2) > 0xffffff)) {
                char *msg;
-               asprintf(&msg, "num_bytes too large: %u",
-                        (unsigned)num_bytes);
+               if (asprintf(&msg, "num_bytes too large: %u",
+                            (unsigned)num_bytes) == -1) {
+                       msg = CONST_DISCARD(char *, "num_bytes too large");
+               }
                smb_panic(msg);
        }
 
@@ -1298,9 +1300,8 @@ static void smb_dump(const char *name, int type, const char *data, ssize_t len)
 
        if (len < 4) len = smb_len(data)+4;
        for (i=1;i<100;i++) {
-               asprintf(&fname, "/tmp/%s.%d.%s", name, i,
-                               type ? "req" : "resp");
-               if (!fname) {
+               if (asprintf(&fname, "/tmp/%s.%d.%s", name, i,
+                            type ? "req" : "resp") == -1) {
                        return;
                }
                fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);