]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Webui: dvrfile - fix the attachment filename cutoff, fixes #3136
authorJaroslav Kysela <perex@perex.cz>
Mon, 12 Oct 2015 10:12:32 +0000 (12:12 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 12 Oct 2015 10:12:32 +0000 (12:12 +0200)
src/webui/webui.c

index 11558f6fddfd300ee3452f689050b9c7d91401de..4180c95c9478261d790545e6fd57c59546bf5e24 100644 (file)
@@ -1468,7 +1468,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
   char *basename;
   char *str, *str0;
   char range_buf[255];
-  char disposition[512];
+  char *disposition = NULL;
   off_t content_len, chunk;
   intmax_t file_start, file_end;
   void *tcp_id;
@@ -1501,7 +1501,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
   }
   if(dvr_entry_verify(de, hc->hc_access, 1)) {
     pthread_mutex_unlock(&global_lock);
-    return HTTP_STATUS_NOT_FOUND;
+    return HTTP_STATUS_UNAUTHORIZED;
   }
 
   fname = tvh_strdupa(filename);
@@ -1517,14 +1517,14 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
     htsbuf_queue_init(&q, 0);
     htsbuf_append_and_escape_url(&q, basename);
     str = htsbuf_to_string(&q);
-    snprintf(disposition, sizeof(disposition),
+    r = 50 + strlen(str0) + strlen(str);
+    disposition = alloca(r);
+    snprintf(disposition, r,
              "attachment; filename=\"%s\"; filename*=UTF-8''%s",
              str0, str);
     htsbuf_queue_flush(&q);
     free(str);
     free(str0);
-  } else {
-    disposition[0] = 0;
   }
 
   fd = tvh_open(fname, O_RDONLY, 0);
@@ -1595,8 +1595,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
 
   http_send_header(hc, range ? HTTP_STATUS_PARTIAL_CONTENT : HTTP_STATUS_OK,
        content, content_len, NULL, NULL, 10, 
-       range ? range_buf : NULL,
-       disposition[0] ? disposition : NULL, NULL);
+       range ? range_buf : NULL, disposition, NULL);
 
   ret = 0;
   if(!hc->hc_no_output) {