]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: Fix the filename builder when no extra dirs are used, fixes #2879, fixes#2884
authorJaroslav Kysela <perex@perex.cz>
Mon, 25 May 2015 06:54:52 +0000 (08:54 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 25 May 2015 06:54:52 +0000 (08:54 +0200)
src/dvr/dvr_rec.c

index 727b09c0e8a76b663df1307c713d49aec4bfe109..3789a25f8c6837b0ca5265d026deda11f933a3dd 100644 (file)
@@ -350,7 +350,7 @@ static str_substitute_t dvr_subs_tally[] = {
 static char *dvr_find_last_path_component(char *path)
 {
   char *res, *p;
-  for (p = res = path; *p; p++) {
+  for (p = path, res = NULL; *p; p++) {
     if (*p == '\\') {
       p++;
     } else {
@@ -475,8 +475,16 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss)
 
   /* Deescape directory path and create directory tree */
   dirsep = dvr_find_last_path_component(path + l);
-  *dirsep = '\0';
-  dirsep++;
+  if (dirsep) {
+    *dirsep = '\0';
+    dirsep++;
+  } else {
+    if (l > 0) {
+      assert(path[l-1] == '/');
+      path[l-1] = '\0';
+    }
+    dirsep = path + l;
+  }
   str_unescape(path, filename, sizeof(filename));
   if (makedirs(filename, cfg->dvr_muxcnf.m_directory_permissions, -1, -1) != 0)
     return -1;