X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-file.c;h=92ed9ff3e170347d65c68fa7afa9450198d7a0d6;hb=d22c11cec4e8c3390bfe6bf16ed07f5d073f0d4a;hp=e826296e1339bb890f95c8d83c2b3a599e30d71e;hpb=e3102a252f2e92de3275bdcf2af96beb85c693e4;p=palacios.git diff --git a/linux_module/iface-file.c b/linux_module/iface-file.c index e826296..92ed9ff 100644 --- a/linux_module/iface-file.c +++ b/linux_module/iface-file.c @@ -56,6 +56,7 @@ static int mkdir_recursive(const char * path, unsigned short perms) { } memset(tmp_str, 0, strlen(path) + 1); + // will terminate tmp_str strncpy(tmp_str, path, strlen(path)); dirname_ptr = tmp_str; @@ -226,7 +227,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat return NULL; } - pfile->path = palacios_alloc(strlen(path)); + pfile->path = palacios_alloc(strlen(path) + 1); if (!pfile->path) { ERROR("Cannot allocate in file open\n"); @@ -234,7 +235,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat palacios_free(pfile); return NULL; } - strncpy(pfile->path, path, strlen(path)); + strncpy(pfile->path, path, strlen(path)); // will terminate pfile->path pfile->guest = guest; palacios_spinlock_init(&(pfile->lock));