Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle the cases where NULL is passed as cap_rightsp to the

filestat_new_entry() function.

Reported by:	Alex Kozlov <spam@rm-rf.kiev.ua>
Approved by:	re (gjb)
  • Loading branch information...
commit 4ab5163697ae354915222d0ef65a54ceebe7a0ee 1 parent 1fb3584
pjd authored
Showing with 14 additions and 10 deletions.
  1. +14 −10 lib/libprocstat/libprocstat.c
View
24 lib/libprocstat/libprocstat.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/ksem.h>
#include <sys/mman.h>
+#include <sys/capability.h>
#define _KERNEL
#include <sys/mount.h>
#include <sys/pipe.h>
@@ -395,7 +396,10 @@ filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
entry->fs_ref_count = refcount;
entry->fs_offset = offset;
entry->fs_path = path;
- entry->fs_cap_rights = *cap_rightsp;
+ if (cap_rightsp != NULL)
+ entry->fs_cap_rights = *cap_rightsp;
+ else
+ cap_rights_init(&entry->fs_cap_rights);
return (entry);
}
@@ -478,21 +482,21 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
/* root directory vnode, if one. */
if (filed.fd_rdir) {
entry = filestat_new_entry(filed.fd_rdir, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
/* current working directory vnode. */
if (filed.fd_cdir) {
entry = filestat_new_entry(filed.fd_cdir, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
/* jail root, if any. */
if (filed.fd_jdir) {
entry = filestat_new_entry(filed.fd_jdir, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -500,14 +504,14 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
if (kp->ki_tracep) {
entry = filestat_new_entry(kp->ki_tracep, PS_FST_TYPE_VNODE, -1,
PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
- PS_FST_UFLAG_TRACE, 0, 0, NULL, 0);
+ PS_FST_UFLAG_TRACE, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
/* text vnode, if one */
if (kp->ki_textvp) {
entry = filestat_new_entry(kp->ki_textvp, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -515,7 +519,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
if ((vp = getctty(kd, kp)) != NULL) {
entry = filestat_new_entry(vp, PS_FST_TYPE_VNODE, -1,
PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
- PS_FST_UFLAG_CTTY, 0, 0, NULL, 0);
+ PS_FST_UFLAG_CTTY, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -578,7 +582,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
}
/* XXXRW: No capability rights support for kvm yet. */
entry = filestat_new_entry(data, type, i,
- to_filestat_flags(file.f_flag), 0, 0, 0, NULL, 0);
+ to_filestat_flags(file.f_flag), 0, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -637,7 +641,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
*/
entry = filestat_new_entry(object.handle,
PS_FST_TYPE_VNODE, -1, fflags,
- PS_FST_UFLAG_MMAP, 0, 0, NULL, 0);
+ PS_FST_UFLAG_MMAP, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -878,7 +882,7 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp,
path = NULL;
entry = filestat_new_entry(kve, PS_FST_TYPE_VNODE, -1,
fflags, PS_FST_UFLAG_MMAP, refcount, offset, path,
- 0);
+ NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
Please sign in to comment.
Something went wrong with that request. Please try again.