View | Details | Raw Unified
Collapse All | Expand All

(-) chkutmp.c (-7 / +8 lines)
 Lines 23-28    Link Here 
 *
 *
 *  Changelog: 
 *  Changelog: 
 *   Ighighi X - Improved speed via break command - 2005/03/27 
 *   Ighighi X - Improved speed via break command - 2005/03/27 
 *   Stewart Gebbie - fixed buffer overrun bug related to MAXREAD and UT_PIDLENGTH - 2007-10-20
 *  
 *  
 */
 */
 Lines 42-48    Link Here 
#endif
#endif
#include <ctype.h>
#include <ctype.h>
#define MAXREAD 1024
#define MAXREAD 4096
#define MAXBUF 4096
#define MAXBUF 4096
#define MAXLENGTH 256
#define MAXLENGTH 256
#define UT_PIDSIZE 12
#define UT_PIDSIZE 12
 Lines 57-69    Link Here 
#endif
#endif
struct ps_line {
struct ps_line {
    char ps_tty[UT_LINESIZE];
    char ps_tty[UT_LINESIZE+1];
    char ps_user[UT_NAMESIZE];
    char ps_user[UT_NAMESIZE+1];
    char ps_args[MAXLENGTH];
    char ps_args[MAXLENGTH+1];
    int ps_pid;
    int ps_pid;
};
};
struct utmp_line {
struct utmp_line {
    char ut_tty[UT_LINESIZE];
    char ut_tty[UT_LINESIZE+1];
    int ut_pid;
    int ut_pid;
    int ut_type;
    int ut_type;
};
};
 Lines 77-83    Link Here 
int fetchps(struct ps_line *psl_p)
int fetchps(struct ps_line *psl_p)
{
{
    FILE *ps_fp;
    FILE *ps_fp;
    char line[MAXREAD + 1], pid[UT_PIDSIZE];
    char line[MAXREAD + 1], pid[UT_PIDSIZE+1];
    char *s, *d;
    char *s, *d;
    struct ps_line *curp = &psl_p[0];
    struct ps_line *curp = &psl_p[0];
    struct ps_line *endp = &psl_p[MAXBUF];
    struct ps_line *endp = &psl_p[MAXBUF];
 Lines 97-103    Link Here 
		while (isspace(*s))	/* skip spaces */
		while (isspace(*s))	/* skip spaces */
		    s++;
		    s++;
		d = pid;
		d = pid;
		for (x = 0; (!isspace(*s)) && (*d++ = *s++) && x <= UT_LINESIZE; x++)	/* grab pid */
		for (x = 0; (!isspace(*s)) && (*d++ = *s++) && x <= UT_PIDSIZE; x++)	/* grab pid */
		    ;
		    ;
		*d = '\0';
		*d = '\0';
		curp->ps_pid = atoi(pid);
		curp->ps_pid = atoi(pid);