From owner-freebsd-bugs Mon Jun 26 14:20:16 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 6F57D37BD14 for ; Mon, 26 Jun 2000 14:20:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id OAA13669; Mon, 26 Jun 2000 14:20:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from vader.creative.net.au (vader.creative.net.au [203.56.168.35]) by hub.freebsd.org (Postfix) with ESMTP id CB2D637B7B4 for ; Mon, 26 Jun 2000 14:12:59 -0700 (PDT) (envelope-from adrian@vader.creative.net.au) Received: (from adrian@localhost) by vader.creative.net.au (8.9.3/8.9.3) id XAA00364; Mon, 26 Jun 2000 23:12:45 +0200 (CEST) (envelope-from adrian) Message-Id: <200006262112.XAA00364@vader.creative.net.au> Date: Mon, 26 Jun 2000 23:12:45 +0200 (CEST) From: adrian@freebsd.org Reply-To: adrian@vader.creative.net.au To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/19535: procfs_rlimit tidyup Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 19535 >Category: kern >Synopsis: procfs_rlimit tidyup >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jun 26 14:20:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Adrian Chadd >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: FreeBSD vader.creative.net.au 5.0-CURRENT FreeBSD 5.0-CURRENT #6: Mon Jun 26 22:54:29 CEST 2000 adrian@vader.creative.net.au:/usr/src/sys/compile/VADER i386 >Description: A quick tidyup of procfs_rlimit.c. Specifically, making the code a little more style(9) compliant, and taking out a char[512] which is bad juju in kernel code. >How-To-Repeat: N/A >Fix: Apply this patch: Index: procfs_rlimit.c =================================================================== RCS file: /home/ncvs/src/sys/miscfs/procfs/procfs_rlimit.c,v retrieving revision 1.5 diff -u -r1.5 procfs_rlimit.c --- procfs_rlimit.c 1999/12/08 08:59:37 1.5 +++ procfs_rlimit.c 2000/06/26 21:10:33 @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -66,41 +67,25 @@ int i; int xlen; int error; - char psbuf[512]; /* XXX - conservative */ + char *psbuf; if (uio->uio_rw != UIO_READ) return (EOPNOTSUPP); - - + psbuf = (char *)malloc(512 * sizeof(char), M_TEMP, M_WAITOK); + /* XXX conservative, but potentially overflowable */ ps = psbuf; - for (i = 0; i < RLIM_NLIMITS; i++) { - - /* - * Add the rlimit ident - */ - + /* Add the rlimit ident */ ps += sprintf(ps, "%s ", rlimit_ident[i]); - - /* - * Replace RLIM_INFINITY with -1 in the string - */ - - /* - * current limit - */ - + /* Replace RLIM_INFINITY with -1 in the string */ + /* current limit */ if (p->p_rlimit[i].rlim_cur == RLIM_INFINITY) { ps += sprintf(ps, "-1 "); } else { ps += sprintf(ps, "%llu ", (unsigned long long)p->p_rlimit[i].rlim_cur); } - - /* - * maximum limit - */ - + /* maximum limit */ if (p->p_rlimit[i].rlim_max == RLIM_INFINITY) { ps += sprintf(ps, "-1\n"); } else { @@ -108,12 +93,10 @@ (unsigned long long)p->p_rlimit[i].rlim_max); } } - /* * This logic is rather tasty - but its from procfs_status.c, so * I guess I'll use it here. */ - xlen = ps - psbuf; xlen -= uio->uio_offset; ps = psbuf + uio->uio_offset; @@ -122,7 +105,7 @@ error = 0; else error = uiomove(ps, xlen, uio); - + free(psbuf, M_TEMP); return (error); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message