allocate mem 1st
This commit is contained in:
parent
d8367cbb3e
commit
aef6890de1
6
Makefile
6
Makefile
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
VERSION := 3
|
VERSION := 3
|
||||||
SUBVERSION := 1
|
SUBVERSION := 1
|
||||||
MINORVERSION := 4
|
MINORVERSION := 5
|
||||||
TARVERSION := 3.1.4
|
TARVERSION := 3.1.5
|
||||||
LIBVERSION := 3.1.4
|
LIBVERSION := 3.1.5
|
||||||
|
|
||||||
############ vars
|
############ vars
|
||||||
|
|
||||||
|
@ -368,6 +368,7 @@ proc_t* readproc(PROCTAB* PT, proc_t* p) {
|
|||||||
#ifdef FLASK_LINUX
|
#ifdef FLASK_LINUX
|
||||||
security_id_t secsid;
|
security_id_t secsid;
|
||||||
#endif
|
#endif
|
||||||
|
pid_t pid; // saved until we have a proc_t allocated for sure
|
||||||
|
|
||||||
/* loop until a proc matching restrictions is found or no more processes */
|
/* loop until a proc matching restrictions is found or no more processes */
|
||||||
/* I know this could be a while loop -- this way is easier to indent ;-) */
|
/* I know this could be a while loop -- this way is easier to indent ;-) */
|
||||||
@ -377,9 +378,8 @@ next_proc: /* get next PID for consideration */
|
|||||||
#define flags (PT->flags)
|
#define flags (PT->flags)
|
||||||
|
|
||||||
if (flags & PROC_PID) {
|
if (flags & PROC_PID) {
|
||||||
pid_t pid = *(PT->pids)++;
|
pid = *(PT->pids)++;
|
||||||
if (unlikely(!pid)) return NULL;
|
if (unlikely(!pid)) return NULL;
|
||||||
p->pid = pid;
|
|
||||||
snprintf(path, sizeof path, "/proc/%d", pid);
|
snprintf(path, sizeof path, "/proc/%d", pid);
|
||||||
} else { /* get next numeric /proc ent */
|
} else { /* get next numeric /proc ent */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -387,7 +387,7 @@ next_proc: /* get next PID for consideration */
|
|||||||
if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return NULL;
|
if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return NULL;
|
||||||
if(likely( likely(*ent->d_name > '0') && likely(*ent->d_name <= '9') )) break;
|
if(likely( likely(*ent->d_name > '0') && likely(*ent->d_name <= '9') )) break;
|
||||||
}
|
}
|
||||||
p->pid = strtoul(ent->d_name, NULL, 10);
|
pid = strtoul(ent->d_name, NULL, 10);
|
||||||
memcpy(path, "/proc/", 6);
|
memcpy(path, "/proc/", 6);
|
||||||
strcpy(path+6, ent->d_name); // trust /proc to not contain evil top-level entries
|
strcpy(path+6, ent->d_name); // trust /proc to not contain evil top-level entries
|
||||||
// snprintf(path, sizeof path, "/proc/%s", ent->d_name);
|
// snprintf(path, sizeof path, "/proc/%s", ent->d_name);
|
||||||
@ -404,11 +404,12 @@ next_proc: /* get next PID for consideration */
|
|||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
p = xcalloc(p, sizeof *p); /* passed buf or alloced mem */
|
p = xcalloc(p, sizeof *p); /* passed buf or alloced mem */
|
||||||
p->euid = sb.st_uid; /* need a way to get real uid */
|
|
||||||
|
|
||||||
|
p->euid = sb.st_uid; /* need a way to get real uid */
|
||||||
#ifdef FLASK_LINUX
|
#ifdef FLASK_LINUX
|
||||||
p->secsid = secsid;
|
p->secsid = secsid;
|
||||||
#endif
|
#endif
|
||||||
|
p->pid = pid;
|
||||||
|
|
||||||
if (flags & PROC_FILLSTAT) { /* read, parse /proc/#/stat */
|
if (flags & PROC_FILLSTAT) { /* read, parse /proc/#/stat */
|
||||||
if (unlikely( file2str(path, "stat", sbuf, sizeof sbuf) == -1 ))
|
if (unlikely( file2str(path, "stat", sbuf, sizeof sbuf) == -1 ))
|
||||||
@ -478,6 +479,7 @@ proc_t* ps_readproc(PROCTAB* PT, proc_t* p) {
|
|||||||
#ifdef FLASK_LINUX
|
#ifdef FLASK_LINUX
|
||||||
security_id_t secsid;
|
security_id_t secsid;
|
||||||
#endif
|
#endif
|
||||||
|
pid_t pid; // saved until we have a proc_t allocated for sure
|
||||||
|
|
||||||
/* loop until a proc matching restrictions is found or no more processes */
|
/* loop until a proc matching restrictions is found or no more processes */
|
||||||
/* I know this could be a while loop -- this way is easier to indent ;-) */
|
/* I know this could be a while loop -- this way is easier to indent ;-) */
|
||||||
@ -491,7 +493,7 @@ next_proc: /* get next PID for consideration */
|
|||||||
if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return NULL;
|
if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return NULL;
|
||||||
if(likely( likely(*ent->d_name > '0') && likely(*ent->d_name <= '9') )) break;
|
if(likely( likely(*ent->d_name > '0') && likely(*ent->d_name <= '9') )) break;
|
||||||
}
|
}
|
||||||
p->pid = strtoul(ent->d_name, NULL, 10);
|
pid = strtoul(ent->d_name, NULL, 10);
|
||||||
memcpy(path, "/proc/", 6);
|
memcpy(path, "/proc/", 6);
|
||||||
strcpy(path+6, ent->d_name); // trust /proc to not contain evil top-level entries
|
strcpy(path+6, ent->d_name); // trust /proc to not contain evil top-level entries
|
||||||
// snprintf(path, sizeof path, "/proc/%s", ent->d_name);
|
// snprintf(path, sizeof path, "/proc/%s", ent->d_name);
|
||||||
@ -505,10 +507,12 @@ next_proc: /* get next PID for consideration */
|
|||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
p = xcalloc(p, sizeof *p); /* passed buf or alloced mem */
|
p = xcalloc(p, sizeof *p); /* passed buf or alloced mem */
|
||||||
|
|
||||||
p->euid = sb.st_uid; /* need a way to get real uid */
|
p->euid = sb.st_uid; /* need a way to get real uid */
|
||||||
#ifdef FLASK_LINUX
|
#ifdef FLASK_LINUX
|
||||||
p->secsid = secsid;
|
p->secsid = secsid;
|
||||||
#endif
|
#endif
|
||||||
|
p->pid = pid;
|
||||||
|
|
||||||
if ((file2str(path, "stat", sbuf, sizeof sbuf)) == -1)
|
if ((file2str(path, "stat", sbuf, sizeof sbuf)) == -1)
|
||||||
goto next_proc; /* error reading /proc/#/stat */
|
goto next_proc; /* error reading /proc/#/stat */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Begin4
|
Begin4
|
||||||
Title: procps
|
Title: procps
|
||||||
Version: 3.1.4
|
Version: 3.1.5
|
||||||
Entered-date: 2002-12-14
|
Entered-date: 2002-12-14
|
||||||
Description: Linux system utilities
|
Description: Linux system utilities
|
||||||
Keywords: procps /proc libproc sysctl pmap
|
Keywords: procps /proc libproc sysctl pmap
|
||||||
@ -8,8 +8,8 @@ Keywords: procps /proc libproc sysctl pmap
|
|||||||
Author: Albert Cahalan, Michael K. Johnson, Jim Warner, etc.
|
Author: Albert Cahalan, Michael K. Johnson, Jim Warner, etc.
|
||||||
Maintained-by: various <procps-feedback@lists.sf.net>
|
Maintained-by: various <procps-feedback@lists.sf.net>
|
||||||
Primary-site: http://procps.sf.net/
|
Primary-site: http://procps.sf.net/
|
||||||
236kB procps-3.1.4.tar.gz
|
236kB procps-3.1.5.tar.gz
|
||||||
Alternate-site: http://www.debian.org/Packages/unstable/base/procps.html
|
Alternate-site: http://www.debian.org/Packages/unstable/base/procps.html
|
||||||
236kB procps-3.1.4.tar.gz
|
236kB procps-3.1.5.tar.gz
|
||||||
Copying-policy: mixed
|
Copying-policy: mixed
|
||||||
End
|
End
|
||||||
|
@ -3,7 +3,7 @@ Summary: System and process monitoring utilities
|
|||||||
Name: procps
|
Name: procps
|
||||||
%define major_version 3
|
%define major_version 3
|
||||||
%define minor_version 1
|
%define minor_version 1
|
||||||
%define revision 4
|
%define revision 5
|
||||||
%define version %{major_version}.%{minor_version}.%{revision}
|
%define version %{major_version}.%{minor_version}.%{revision}
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
Release: 1
|
Release: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user