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.


Paranoid error checking in userspace utils
Kyle Hale [Wed, 27 Jun 2012 22:46:15 +0000 (17:46 -0500)]
linux_usr/v3_create.c
linux_usr/v3_create_bind.c
linux_usr/v3_ctrl.c
linux_usr/v3_env_inject.c
linux_usr/v3_mem.c
linux_usr/v3_user_host_dev_example.c
linux_usr/v3_user_keyed_stream_example.c

index 4bc5ab5..3605702 100644 (file)
@@ -52,6 +52,10 @@ int main(int argc, char* argv[]) {
     
     // load guest image into user memory
     guest_img.guest_data = malloc(guest_img.size);
+    if (!guest_img.guest_data) {
+            printf("ERROR: could not allocate memory for guest image\n");
+            return -1;
+    }
 
     read_file(guest_fd, guest_img.size, guest_img.guest_data);
     
index feaf170..f8a2be9 100644 (file)
@@ -124,6 +124,11 @@ int main(int argc, char* argv[]) {
     
     // load guest image into user memory
     guest_img.guest_data = malloc(guest_img.size);
+    if (!guest_img.guest_data) {
+            printf("ERROR: could not allocate memory for guest image\n");
+            return -1;
+    }
+
 
     read_file(guest_fd, guest_img.size, guest_img.guest_data);
     
index fc8aaae..984045b 100644 (file)
@@ -51,6 +51,10 @@ int main(int argc, char* argv[]) {
     
     // load guest image into user memory
     guest_img.guest_data = malloc(guest_img.size);
+    if (!guest_img.guest_data) {
+        printf("ERROR: Could not allocate memory for guest image\n");
+        return -1;
+    }
 
     read_file(guest_fd, guest_img.size, guest_img.guest_data);
     
index a541427..f9eb854 100644 (file)
@@ -52,6 +52,10 @@ int main (int argc, char **argv) {
         if (tmp_str[len] == '\n')
             tmp_str[len] = 0;
         strings[i] = (char*)malloc(MAX_STRING_LEN);
+        if (!strings[i]) {
+                fprintf(stderr, "Error allocating space for variable\n");
+                return -1;
+        }
         strcpy(strings[i], tmp_str);
         i++;
     }
index 9f7ac00..7949f3a 100644 (file)
@@ -108,6 +108,11 @@ int main(int argc, char * argv[]) {
        if (bitmap_entries % 8) size++;
 
        bitmap = malloc(size);
+    if (!bitmap) {
+            printf("ERROR: could not allocate space for bitmap\n");
+            return -1;
+    }
+
        memset(bitmap, 0, size);
 
        for (i = 0; j < bitmap_entries - 1; i++) {
index 833f3c5..4f8144e 100644 (file)
@@ -31,6 +31,10 @@ int do_work(struct palacios_host_dev_host_request_response *req,
     //
     // now built a response
     *resp = malloc(sizeof(struct palacios_host_dev_host_request_response) + datasize);
+    if (!*resp) {
+        fprintf(stderr, "ERROR: could not allocate memory for response\n");
+        return -1;
+    }
     (*resp)->data_len = sizeof(struct palacios_host_dev_host_request_response) + datasize;
 
     //
index 1e126da..1886b73 100644 (file)
@@ -35,6 +35,11 @@ int do_work(struct palacios_user_keyed_stream_op *req,
 
     // now built a response
     *resp = malloc(sizeof(struct palacios_user_keyed_stream_op) + datasize);
+    if (!*resp) {
+        fprintf(stderr, "ERROR: could not allocate space for response\n");
+        return -1;
+    }
+
     (*resp)->len = sizeof(struct palacios_user_keyed_stream_op) + datasize;
     (*resp)->buf_len = datasize;
     (*resp)->type = req->type;