summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-12-30 15:11:16 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2005-12-30 15:11:16 +0100
commit3f21bf20c52599cc6dbe252488dc3dda36402f3c (patch)
tree57bb30be8f24e013ec15bcdcea60c307a3d7baf2 /device.c
parent924827fcbe0e7276c458c051d1f56cb8f4ca19a1 (diff)
downloadvdr-3f21bf20c52599cc6dbe252488dc3dda36402f3c.tar.gz
vdr-3f21bf20c52599cc6dbe252488dc3dda36402f3c.tar.bz2
New option '-g'; fixed security hole CAN-2005-0071 when grabbing to file
Diffstat (limited to 'device.c')
-rw-r--r--device.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/device.c b/device.c
index fb5360c8..cd8a1402 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 1.113 2005/12/29 14:51:41 kls Exp $
+ * $Id: device.c 1.114 2005/12/30 13:48:29 kls Exp $
*/
#include "device.h"
@@ -330,12 +330,12 @@ uchar *cDevice::GrabImage(int &Size, bool Jpeg, int Quality, int SizeX, int Size
bool cDevice::GrabImageFile(const char *FileName, bool Jpeg, int Quality, int SizeX, int SizeY)
{
int result = 0;
- FILE *f = fopen(FileName, "wb");
- if (f) {
+ int fd = open(FileName, O_WRONLY | O_CREAT | O_NOFOLLOW | O_TRUNC, DEFFILEMODE);
+ if (fd >= 0) {
int ImageSize;
uchar *Image = GrabImage(ImageSize, Jpeg, Quality, SizeX, SizeY);
if (Image) {
- if (fwrite(Image, ImageSize, 1, f) == 1)
+ if (safe_write(fd, Image, ImageSize) == ImageSize)
isyslog("grabbed image to %s", FileName);
else {
LOG_ERROR_STR(FileName);
@@ -345,7 +345,7 @@ bool cDevice::GrabImageFile(const char *FileName, bool Jpeg, int Quality, int Si
}
else
result |= 1;
- fclose(f);
+ close(fd);
}
else {
LOG_ERROR_STR(FileName);