vdr 1.3.38: SVDRP grab filename

Message ID dpu9h5$ftp$1@video.local.muempf.de
State New
Headers

Commit Message

Stefan Huelswitt Jan. 9, 2006, 6:20 p.m. UTC
  Hi,

as far as I see, the new SVDRP grab code always prepends the
given filename with the grabdirectory (given with -g) even if the
filename in the grab command is actualy a full path.

Is this change intended?

I yes, may be this should be documented somewhere, as it's not
backward compatible with older vdr versions.
But I don't see a reason why it's necessary. The path check later
will catch a wrong path anyways.

I'd suggested something like (defaulting to jpeg with no filename
extention for enhanced backward compatibility too):


Regards.
  

Comments

Klaus Schmidinger Jan. 14, 2006, 11:43 a.m. UTC | #1
Stefan Huelswitt wrote:
> Hi,
> 
> as far as I see, the new SVDRP grab code always prepends the
> given filename with the grabdirectory (given with -g) even if the
> filename in the grab command is actualy a full path.
> 
> Is this change intended?
> 
> I yes, may be this should be documented somewhere, as it's not
> backward compatible with older vdr versions.
> But I don't see a reason why it's necessary. The path check later
> will catch a wrong path anyways.
> 
> I'd suggested something like (defaulting to jpeg with no filename
> extention for enhanced backward compatibility too):
> 
> --- svdrp.c.orig	2005-12-30 16:42:29.000000000 +0100
> +++ svdrp.c	2006-01-09 19:15:51.000000000 +0100
> @@ -682,8 +682,7 @@
>       else if (strcmp(FileName, "-") == 0)
>          FileName = NULL;
>       else {
> -        Reply(501, "Missing filename extension in \"%s\"", FileName);
> -        return;
> +        Jpeg = true;

This would allow overwriting files with extensions other
than ".jpeg", ".jpg" or ".pnm" - is this really what you want?

>          }
>       // image quality (and obsolete type):
>       if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
> @@ -729,10 +728,13 @@
>       char RealFileName[PATH_MAX];
>       if (FileName) {
>          if (grabImageDir) {
> -           char *s;
> -           asprintf(&s, "%s/%s", grabImageDir, FileName);
> -           FileName = s;
> -           char *slash = strrchr(FileName, '/'); // there definitely is one
> +           char *s = 0;
> +           char *slash = strrchr(FileName, '/');
> +           if (!slash) {
> +              asprintf(&s, "%s/%s", grabImageDir, FileName);
> +              FileName = s;
> +              }
> +           slash = strrchr(FileName, '/'); // there definitely is one
>             *slash = 0;
>             char *r = realpath(FileName, RealFileName);
>             *slash = '/';

Ok, that sounds reasonable.

Klaus
  
Stefan Huelswitt Jan. 14, 2006, 1:40 p.m. UTC | #2
On 14 Jan 2006 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:
> Stefan Huelswitt wrote:
>
>> --- svdrp.c.orig	2005-12-30 16:42:29.000000000 +0100
>> +++ svdrp.c	2006-01-09 19:15:51.000000000 +0100
>> @@ -682,8 +682,7 @@
>>       else if (strcmp(FileName, "-") == 0)
>>          FileName = NULL;
>>       else {
>> -        Reply(501, "Missing filename extension in \"%s\"", FileName);
>> -        return;
>> +        Jpeg = true;
> 
> This would allow overwriting files with extensions other
> than ".jpeg", ".jpg" or ".pnm" - is this really what you want?

Actualy it allows overwriting files with no extention only.

I find it convinient to be backward compatible.
As the whole operation is limited to the grab directory anyways,
security considerations are negligible IMHO.

Regards.
  
Klaus Schmidinger Jan. 14, 2006, 1:46 p.m. UTC | #3
Stefan Huelswitt wrote:
> On 14 Jan 2006 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:
> 
>>Stefan Huelswitt wrote:
>>
>>
>>>--- svdrp.c.orig	2005-12-30 16:42:29.000000000 +0100
>>>+++ svdrp.c	2006-01-09 19:15:51.000000000 +0100
>>>@@ -682,8 +682,7 @@
>>>      else if (strcmp(FileName, "-") == 0)
>>>         FileName = NULL;
>>>      else {
>>>-        Reply(501, "Missing filename extension in \"%s\"", FileName);
>>>-        return;
>>>+        Jpeg = true;
>>
>>This would allow overwriting files with extensions other
>>than ".jpeg", ".jpg" or ".pnm" - is this really what you want?
> 
> 
> Actualy it allows overwriting files with no extention only.
> 
> I find it convinient to be backward compatible.
> As the whole operation is limited to the grab directory anyways,
> security considerations are negligible IMHO.

And what's the point in writing to a file without an extension?

Klaus
  
Stefan Huelswitt Jan. 14, 2006, 1:55 p.m. UTC | #4
On 14 Jan 2006 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:
> Stefan Huelswitt wrote:
>> 
>> Actualy it allows overwriting files with no extention only.
>> 
>> I find it convinient to be backward compatible.
>> As the whole operation is limited to the grab directory anyways,
>> security considerations are negligible IMHO.
> 
> And what's the point in writing to a file without an extension?

For me the point was, that vdradmin uses a grab file without
extention since ever. vdr 1.3.38 broke that.

I think it's a good idea to behave in a backward compatible way
whenever possible.

Jut my 2 cents.

Regards.
  

Patch

--- svdrp.c.orig	2005-12-30 16:42:29.000000000 +0100
+++ svdrp.c	2006-01-09 19:15:51.000000000 +0100
@@ -682,8 +682,7 @@ 
      else if (strcmp(FileName, "-") == 0)
         FileName = NULL;
      else {
-        Reply(501, "Missing filename extension in \"%s\"", FileName);
-        return;
+        Jpeg = true;
         }
      // image quality (and obsolete type):
      if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
@@ -729,10 +728,13 @@ 
      char RealFileName[PATH_MAX];
      if (FileName) {
         if (grabImageDir) {
-           char *s;
-           asprintf(&s, "%s/%s", grabImageDir, FileName);
-           FileName = s;
-           char *slash = strrchr(FileName, '/'); // there definitely is one
+           char *s = 0;
+           char *slash = strrchr(FileName, '/');
+           if (!slash) {
+              asprintf(&s, "%s/%s", grabImageDir, FileName);
+              FileName = s;
+              }
+           slash = strrchr(FileName, '/'); // there definitely is one
            *slash = 0;
            char *r = realpath(FileName, RealFileName);
            *slash = '/';