}
memset(tmp_str, 0, strlen(path) + 1);
+ // will terminate tmp_str
strncpy(tmp_str, path, strlen(path));
dirname_ptr = tmp_str;
{
dentry = kern_path_create(AT_FDCWD, pathname, &tmp_path, 1);
- if (IS_ERR(dentry)) {
+ if (!dentry || IS_ERR(dentry)) {
return 0;
}
#endif
- if (!IS_ERR(dentry)) {
+ if (!(!dentry || IS_ERR(dentry))) {
ret = vfs_mkdir(path_ptr->dentry->d_inode, dentry, perms);
}
pfile->mode |= O_LARGEFILE;
- pfile->filp = filp_open(path, pfile->mode, 0);
+ pfile->filp = filp_open(path, pfile->mode, 0600); // rw------- to start
- if (IS_ERR(pfile->filp)) {
+ if (!pfile->filp || IS_ERR(pfile->filp)) {
ERROR("Cannot open file: %s\n", path);
palacios_free(pfile);
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");
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));