aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-05-31 06:24:42 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-05-31 06:24:42 +0000
commita53d8337c13f485875cad24edf74b0287b37600b (patch)
tree9dc0b3dd899d3ce3bee854496962f756458260f7
parentea5453f570c5186379745a10054280f47a809299 (diff)
downloadlcd4linux-a53d8337c13f485875cad24edf74b0287b37600b.tar.gz
[lcd4linux @ 2004-05-31 06:24:42 by reinelt]
fixed symlink security issue with the image driver git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@450 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to '')
-rw-r--r--drv_Image.c32
-rw-r--r--lcd4linux.conf.sample4
2 files changed, 29 insertions, 7 deletions
diff --git a/drv_Image.c b/drv_Image.c
index 8b6246a..82f4e9a 100644
--- a/drv_Image.c
+++ b/drv_Image.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Image.c,v 1.2 2004/05/29 23:30:20 reinelt Exp $
+/* $Id: drv_Image.c,v 1.3 2004/05/31 06:24:42 reinelt Exp $
*
* new style Image (PPM/PNG) Driver for LCD4Linux
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_Image.c,v $
+ * Revision 1.3 2004/05/31 06:24:42 reinelt
+ *
+ * fixed symlink security issue with the image driver
+ *
* Revision 1.2 2004/05/29 23:30:20 reinelt
*
* fixed a compiler issue with drv_Image.c (thanks to Frank Stratmann)
@@ -149,7 +153,13 @@ static int drv_IMG_flush_PPM (void)
snprintf (path, sizeof(path), output, seq++);
qprintf(tmp, sizeof(tmp), "%s.tmp", path);
- if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0644))<0) {
+ // remove the file
+ unlink (tmp);
+
+ // avoid symlink security hole:
+ // open it with O_EXCL will fail if the file exists.
+ // This should not happen because we just unlinked it.
+ if ((fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0644))<0) {
error ("%s: open(%s) failed: %s", Name, tmp, strerror(errno));
return -1;
}
@@ -205,7 +215,7 @@ static int drv_IMG_flush_PNG (void)
static int seq = 0;
int xsize, ysize, row, col;
char path[256], tmp[256];
- FILE *fp;
+ FILE *fp; int fd;
gdImagePtr im;
int bg, hg, fg;
@@ -244,8 +254,20 @@ static int drv_IMG_flush_PNG (void)
snprintf (path, sizeof(path), output, seq++);
qprintf (tmp, sizeof(tmp), "%s.tmp", path);
- if ((fp = fopen(tmp, "w")) == NULL) {
- error("%s: fopen(%s) failed: %s\n", Name, tmp, strerror(errno));
+ // remove the file
+ unlink (tmp);
+
+ // avoid symlink security hole:
+ // open it with O_EXCL will fail if the file exists.
+ // This should not happen because we just unlinked it.
+ if ((fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0644))<0) {
+ error ("%s: open(%s) failed: %s", Name, tmp, strerror(errno));
+ return -1;
+ }
+
+ if ((fp = fdopen(fd, "w")) == NULL) {
+ error("%s: fdopen(%s) failed: %s\n", Name, tmp, strerror(errno));
+ close (fd);
return -1;
}
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index aaae679..b61807d 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -515,14 +515,14 @@ Layout testMySQL {
#Display 'MI240'
#Display 'HD44780-20x4'
#Display 'M50530-24x8'
-Display 'CF631'
+#Display 'CF631'
#Display 'CF632'
#Display 'CF633'
#Display 'Curses'
#Display 'USBLCD'
#Display 'T6963-240x64'
#Display 'XWindow'
-#Display 'Image'
+Display 'Image'
#Layout 'Default'
#Layout 'L16x2'
itle='2011-07-27 02:36:25 +0000'>2011-07-27patch to replace outdate library libmpd with recent library libmpdclient from...michael2-240/+427 2011-07-27lcd4linux-wireless.patch from Hans de Goedemichael1-1/+1 2011-07-27st2205-width-height-swap.patch from Hans de Goedemichael1-2/+2 2011-07-27hwmon patch from Hans de Goedemichael1-0/+14 2011-07-27patch to support SureElectronicsDE-LD023 from Matt Joicemichael1-3/+16 2011-05-06Fixed keypad widget in GLCD2USBharbaum1-0/+7 2011-02-12timer.c: fixed detection of positive clock skew (and some typos)mzuther4-10/+10 2011-01-23timer.c: fixed clock skew detectionmzuther1-26/+46 2011-01-23timer.c: skip intermediate timer intervalsmzuther2-16/+46 2011-01-05fix for a bug introduced in the DE-LD021 drivermichael1-3/+3 2011-01-04indentationmichael2-3/+3 2011-01-04support for Sure Electronics DE-LD021 by Natanael Olaizmichael1-10/+8 2011-01-02driver for EFN LED modules by Tilman Glötznermichael9-21/+469 2010-11-28commented, corrected and beautified both timer and timer group codemzuther11-197/+511 2010-11-27finished commenting the timer codemzuther2-46/+138 2010-11-20started commenting the timer codemzuther5-52/+170 2010-11-19Added brightness support for GLCD2USBharbaum5-28/+8014