Date: Wed, 9 Oct 2013 20:58:51 +0000 (UTC) From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256242 - head/lib/libprocstat Message-ID: <201310092058.r99KwpmP024302@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pjd Date: Wed Oct 9 20:58:50 2013 New Revision: 256242 URL: http://svnweb.freebsd.org/changeset/base/256242 Log: 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) Modified: head/lib/libprocstat/libprocstat.c Modified: head/lib/libprocstat/libprocstat.c ============================================================================== --- head/lib/libprocstat/libprocstat.c Wed Oct 9 20:47:20 2013 (r256241) +++ head/lib/libprocstat/libprocstat.c Wed Oct 9 20:58:50 2013 (r256242) @@ -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 ty 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 *p /* 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 *p 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 *p 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 *p } /* 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 @@ do_mmapped: */ 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 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310092058.r99KwpmP024302>