X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-file.c;h=92ed9ff3e170347d65c68fa7afa9450198d7a0d6;hb=d22c11cec4e8c3390bfe6bf16ed07f5d073f0d4a;hp=78c4e0b901448b2d1996bacef83f184cbf148656;hpb=0b2115047303e779be8578e9802cfa55d1767c7b;p=palacios.git diff --git a/linux_module/iface-file.c b/linux_module/iface-file.c index 78c4e0b..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; @@ -218,7 +219,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat pfile->mode |= O_LARGEFILE; - pfile->filp = filp_open(path, pfile->mode, 0); + pfile->filp = filp_open(path, pfile->mode, 0600); // rw------- to start if (!pfile->filp || IS_ERR(pfile->filp)) { ERROR("Cannot open file: %s\n", path); @@ -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));