From 8894546f1f9106650a4a8214d9c9477decf29f58 Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Sat, 20 Aug 2005 19:45:53 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20potentional=20security=20issue.=20Thanks?= =?UTF-8?q?=20to=20Javier=20Fern=C3=A1ndez-Sanguino=20Pe=C3=B1a=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@3060 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/pwm/pwmconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index 48415f32..dbc16956 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -465,9 +465,11 @@ function TestMinStop { function SaveConfig { echo echo "Saving configuration to $FCCONFIG..." - egrep -v '(INTERVAL|FCTEMPS|FCFANS|MAXTEMP|MINTEMP|MINSTART|MINSTOP)' $FCCONFIG >/tmp/fancontrol - echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>/tmp/fancontrol - mv /tmp/fancontrol $FCCONFIG + tmpfile=`tempfile` || { echo "$0: Cannot create temporary file" >&2; exit 1; } + trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15 + egrep -v '(INTERVAL|FCTEMPS|FCFANS|MAXTEMP|MINTEMP|MINSTART|MINSTOP)' $FCCONFIG >$tmpfile + echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>$tmpfile + mv $tmpfile $FCCONFIG #check if file was written correctly echo 'Configuration saved' }