summaryrefslogtreecommitdiffstats
path: root/pw/pw_user.c
diff options
context:
space:
mode:
authorDon Lewis <truckman@FreeBSD.org>2016-05-24 05:02:24 +0000
committerDon Lewis <truckman@FreeBSD.org>2016-05-24 05:02:24 +0000
commit464e017819a03cb8d878c2dae86d2d76b4f93a67 (patch)
treebbfb16431a0c90f11c1c4cce971c9bd3ba171146 /pw/pw_user.c
parentb05f0f68b0bba4ffbd664928f8c8e1c97b460496 (diff)
downloadpw-darwin-464e017819a03cb8d878c2dae86d2d76b4f93a67.tar.gz
pw-darwin-464e017819a03cb8d878c2dae86d2d76b4f93a67.tar.zst
pw-darwin-464e017819a03cb8d878c2dae86d2d76b4f93a67.zip
Fix CID 1006692 in /usr/sbin/pw pw_log() function and other fixes
The length of the name returned from the $LOGNAME and $USER can be very long and it was being concatenated to a fixed length buffer with no bounds checking. Fix this problem by limiting the length of the name copied. Additionally, this name is actually used to create a format string to be used in adding log file entries so embedded % characters in the name could confuse *printf(), and embedded whitespace could confuse a log file parser. Handle the former by escaping each % with an additional %, and handle the latter by simply stripping it out. Clean up the code by moving the variable declarations to the top of the function, formatting them to conform with style, and moving intialization elsewhere. Reduce code indentation by returning early in a couple of places. Reported by: Coverity CID: 1006692 Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D6490
Diffstat (limited to 'pw/pw_user.c')
0 files changed, 0 insertions, 0 deletions