Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Jul 2005 10:28:35 +0000 (UTC)
From:      Alexander Leidinger <netchild@FreeBSD.org>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/sys/kern kern_environment.c
Message-ID:  <200507311028.j6VASZJo054159@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
netchild    2005-07-31 10:28:35 UTC

  FreeBSD src repository

  Modified files:
    sys/kern             kern_environment.c 
  Log:
  Add bounds checking to the setenv part of the kernel environment.
  
  This has no security implications since only root is allowed to use
  kenv(1) (and corrupt the kernel memory after adding too much variables
  previous to this commit).
  
  This is based upon the PR [1] mentioned below, but extended to check both
  bounds (in case of an overflow of the counting variable) and to comply
  to the style of the function. An overflow of the counting variable
  shouldn't happen after adding the check for the upper bound, but better
  safe than sorry (in case some other function in the kernel overwrites
  random memory).
  
  An interested soul may want to add a printf to notify root in case the
  bounds are hit.
  
  Also allocate KENV_SIZE+1 entries (the array is NULL-terminated), since
  the comment for KENV_SIZE says it's the maximum number of environment
  strings. [2]
  
  PR:             83687 [1]
  Submitted by:   Harry Coin <harrycoin@qconline.com> [1]
  Submitted by:   Ariff Abdullah <skywizard@MyBSD.org.my> [2]
  
  Revision  Changes    Path
  1.40      +10 -1     src/sys/kern/kern_environment.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507311028.j6VASZJo054159>