Re: [vdr] [Patch] crashes with old recordings without info file

2011-04-03 Thread Mika Laitio

I wonder who is actually calling cRecordingInfo::Read(FILE *f) with

a NULL pointer? In VDR's own code all calls to that function are
made sure to get a non-NULL pointer:


Yes, the real reason is in the vdrrip plugin that I cloned from
http://projects.vdr-developer.org/git/

It has this kind of code which always assumes that info file always exist.

void cMovie::setLengthVDR() {
char *infoFile = NULL;
asprintf(&infoFile, "%s%s", Dir, OldRecording ? "/info.vdr" : 
"/info");

dsyslog ("[vdrrip] reading recording info %s ",infoFile);
cRecordingInfo *crec = new cRecordingInfo(Dir);
FILE *f = fopen(infoFile, "r");
if (crec->Read(f)) {

I just thought that it would be good to fix that in vdr code also.
But I think putting the metod now private will also quarantee NULL 
pointer check :-)


Mika

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [Patch] crashes with old recordings without info file

2011-04-03 Thread Klaus Schmidinger

On 03.04.2011 12:23, Mika Laitio wrote:

I have some old recordings made on 2005 which does not have info file. This 
caused vdr 1.7.17 to crash because
in tools.c line 1194 there is no check whether the file parameter passed is 
NULL or not. Real cause for the crash is in the vdrrip plugins which
should handle the case where the info file does not exist on setLengthVDR 
method on movie.c.
Anyway, it's propably good idea also to has the NULL check's in vdr's own code. 
Patches attached for tools.c and recording.c.


I wonder who is actually calling cRecordingInfo::Read(FILE *f) with
a NULL pointer? In VDR's own code all calls to that function are
made sure to get a non-NULL pointer:


bool cRecordingInfo::Read(void)
{
  bool Result = false;
  if (fileName) {
 FILE *f = fopen(fileName, "r");
 if (f) {
if (Read(f))


cRecording::cRecording(const char *FileName)
{
  ...
 FILE *f = fopen(InfoFileName, "r");
 if (f) {
if (!info->Read(f))


Since it doesn't make any sense to call cRecordingInfo::Read(FILE *f)
from outside cRecordingInfo, I made that function private now.
This may break some plugin, but that should have called
cRecordingInfo::Read(void), anyway.

Klaus

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] [Patch] crashes with old recordings without info file

2011-04-03 Thread Mika Laitio
I have some old recordings made on 2005 which does not have info file. 
This caused vdr 1.7.17 to crash because
in tools.c line 1194 there is no check whether the file parameter passed 
is NULL or not. Real cause for the crash is in the vdrrip plugins which
should handle the case where the info file does not exist on 
setLengthVDR method on movie.c.
Anyway, it's propably good idea also to has the NULL check's in vdr's 
own code. Patches attached for tools.c and recording.c.


#0  0x7640e8ff in getdelim () from /lib64/libc.so.6
#1  0x004fcd48 in getline (this=0x7fffde30, f=0x0) at 
/usr/include/bits/stdio.h:118

#2  cReadLine::Read (this=0x7fffde30, f=0x0) at tools.c:1194
#3  0x004cc383 in cRecordingInfo::Read (this=0xc29bc0, f=0x0) at 
recording.c:419
#4  0x7fffef0397a0 in cMovie::setLengthVDR() () from 
./PLUGINS/lib/libvdr-vdrrip.so.1.7.17
#5  0x7fffef03af00 in cMovie::cMovie(char const*, char const*) () 
from ./PLUGINS/lib/libvdr-vdrrip.so.1.7.17
#6  0x7fffef0367d7 in cMenuVdrripMovie::cMenuVdrripMovie(char 
const*, char const*) () from ./PLUGINS/lib/libvdr-vdrrip.so.1.7.17
#7  0x7fffef03807d in cMenuVdrripEncode::ProcessKey(eKeys) () from 
./PLUGINS/lib/libvdr-vdrrip.so.1.7.17


[lamikr@tinka Prisma:_Einstein_ja_kaiken_teoria]$ ls -la 
2005-04-21.20\:58.50.99.rec/

total 1338080
drwxr-xr-x 2 76 76   4096 2008-05-17 17:48 ./
drwxr-xr-x 3 76 76   4096 2008-05-17 17:46 ../
-rw-r--r-- 1 76 76 1369418800 2008-05-17 17:48 001.vdr
-rw-r--r-- 1 76 76 727968 2008-05-17 17:48 index.vdr
-rw-r--r-- 1 76 76  4 2008-05-17 17:48 resume.vdr
-rw-r--r-- 1 76 76441 2008-05-17 17:48 summary.vdr


>From ef2f4122b44abbc4cae7876bb8566ed95151cdf5 Mon Sep 17 00:00:00 2001
From: Mika Laitio 
Date: Sun, 3 Apr 2011 13:06:55 +0300
Subject: [PATCH 1/2] NULL pointer check to cReadline.read in tools.c

Signed-off-by: Mika Laitio 
---
 tools.c |   22 --
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/tools.c b/tools.c
index d03595e..c09a9b0 100644
--- a/tools.c
+++ b/tools.c
@@ -1191,18 +1191,20 @@ cReadLine::~cReadLine()
 
 char *cReadLine::Read(FILE *f)
 {
-  int n = getline(&buffer, &size, f);
-  if (n > 0) {
- n--;
- if (buffer[n] == '\n') {
-buffer[n] = 0;
-if (n > 0) {
-   n--;
-   if (buffer[n] == '\r')
-  buffer[n] = 0;
+  if (f != NULL) {
+ int n = getline(&buffer, &size, f);
+ if (n > 0) {
+n--;
+if (buffer[n] == '\n') {
+   buffer[n] = 0;
+   if (n > 0) {
+  n--;
+  if (buffer[n] == '\r')
+ buffer[n] = 0;
+  }
}
+return buffer;
 }
- return buffer;
  }
   return NULL;
 }
-- 
1.7.3.4

>From 18385a3641f8fb6003824462b0e982edbf248f93 Mon Sep 17 00:00:00 2001
From: Mika Laitio 
Date: Sun, 3 Apr 2011 13:12:20 +0300
Subject: [PATCH 2/2] NULL pointer check for file at cRecordingInfo::Read(FILE 
*f)

Signed-off-by: Mika Laitio 
---
 recording.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/recording.c b/recording.c
index 02a6e61..07528a2 100644
--- a/recording.c
+++ b/recording.c
@@ -412,7 +412,7 @@ void cRecordingInfo::SetFramesPerSecond(double 
FramesPerSecond)
 
 bool cRecordingInfo::Read(FILE *f)
 {
-  if (ownEvent) {
+  if (f && ownEvent) {
  cReadLine ReadLine;
  char *s;
  int line = 0;
-- 
1.7.3.4

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr