Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Cleanup and sanity-checking of before/after null-check and copy+paste errors (Coverit...
[palacios.git] / linux_module / iface-keyed-stream.c
index 3fa8ebe..a6fb960 100644 (file)
@@ -310,7 +310,7 @@ static v3_keyed_stream_t open_stream_mem(char *url,
                    return 0;
                }
 
-               strcpy(mykey,url+4);
+               strcpy(mykey,url+4); // will fit
                
                mks = (struct mem_keyed_stream *) palacios_alloc(sizeof(struct mem_keyed_stream));
 
@@ -382,7 +382,7 @@ static v3_keyed_stream_key_t open_key_mem(v3_keyed_stream_t stream,
            return 0;
        }
 
-       strcpy(mykey,key);
+       strcpy(mykey,key); // will fit
 
        m = create_mem_stream();
        
@@ -431,7 +431,7 @@ static void preallocate_hint_key_mem(v3_keyed_stream_t stream,
            return;
        }
        
-       strcpy(mykey,key);
+       strcpy(mykey,key); // will fit
        
        m = create_mem_stream_internal(size);
        
@@ -684,7 +684,7 @@ static v3_keyed_stream_t open_stream_file(char *url,
        return 0;
     }
     
-    strcpy(fks->path,url+5);
+    strcpy(fks->path,url+5); // will fit
     
     fks->stype=STREAM_FILE;
 
@@ -726,7 +726,7 @@ static v3_keyed_stream_t open_stream_file(char *url,
 
            de = lookup_create(&nd,1);
 
-           if (IS_ERR(de)) { 
+           if (!de || IS_ERR(de)) { 
                ERROR("cannot allocate dentry\n");
                goto fail_out;
            }
@@ -796,11 +796,12 @@ static v3_keyed_stream_key_t open_key_file(v3_keyed_stream_t stream,
        ERROR("cannot allocate file keyed stream for key %s\n",key);
        return 0;
     }
+    // this sequence will fit and terminate with a zero
     strcpy(path,fks->path);
     strcat(path,"/");
     strcat(path,key);
     
-    fs = (struct file_stream *) palacios_alloc(sizeof(struct file_stream *));
+    fs = (struct file_stream *) palacios_alloc(sizeof(struct file_stream));
     
     if (!fs) { 
        ERROR("cannot allocate file keyed stream for key %s\n",key);
@@ -810,9 +811,9 @@ static v3_keyed_stream_key_t open_key_file(v3_keyed_stream_t stream,
 
     fs->stype=STREAM_FILE;
 
-    fs->f = filp_open(path,O_RDWR|O_CREAT,0600);
-    
-    if (IS_ERR(fs->f)) {
+    fs->f = filp_open(path,O_RDWR|O_CREAT|O_LARGEFILE,0600);
+
+    if (!fs->f || IS_ERR(fs->f)) {
        ERROR("cannot open relevent file \"%s\" for stream \"file:%s\" and key \"%s\"\n",path,fks->path,key);
        palacios_free(fs);
        palacios_free(path);
@@ -1759,12 +1760,12 @@ static unsigned int keyed_stream_poll_user(struct file *filp, poll_table *wait)
     
     palacios_spinlock_lock_irqsave(&(s->lock), flags);
 
+    poll_wait(filp, &(s->user_wait_queue), wait);
+
     if (s->waiting) {
        palacios_spinlock_unlock_irqrestore(&(s->lock), flags);
        return POLLIN | POLLRDNORM;
     }
-
-    poll_wait(filp, &(s->user_wait_queue), wait);
     
     palacios_spinlock_unlock_irqrestore(&(s->lock), flags);
 
@@ -2082,7 +2083,7 @@ static v3_keyed_stream_key_t open_key_user(v3_keyed_stream_t stream, char *key)
 
     s->op->type = PALACIOS_KSTREAM_OPEN_KEY;
     s->op->buf_len = len;
-    strncpy(s->op->buf,key,len);
+    strncpy(s->op->buf,key,len); // will terminate buffer
 
     // enter with it locked
     if (do_request_to_response(s,&flags)) { 
@@ -2779,7 +2780,7 @@ static sint64_t write_key_net(v3_keyed_stream_t stream, v3_keyed_stream_key_t ke
            ERROR("Could not send tag length in write_key_net\n");
            return -1;
        } 
-       if (send_msg(nks->ns,tag,taglen)!=len) { 
+       if (send_msg(nks->ns,tag,taglen)!=taglen) { 
            ERROR("Could not send tag in write_key_net\n");
            return -1;
        }
@@ -3177,6 +3178,7 @@ static int guest_init_keyed_streams(struct v3_guest * guest, void ** vm_data )
 
 static int guest_deinit_keyed_streams(struct v3_guest * guest, void * vm_data)
 {
+    remove_guest_ctrl(guest, V3_VM_KSTREAM_USER_CONNECT);
 
     return 0;
 }