Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions e2e/test_m3u.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,9 +1060,9 @@ def test_merged_url_overflow_returns_500(self, r2h_binary):
rtsp = MockRTSPServer(num_packets=500)
rtsp.start()
try:
# ~600 bytes per side guarantees the merged URL exceeds 1024.
configured_pad = "padconfigured=" + ("a" * 600)
request_pad = "padrequest=" + ("b" * 600)
# ~1200 bytes per side guarantees the merged URL exceeds 2048.
configured_pad = "padconfigured=" + ("a" * 1200)
Comment thread
stackia marked this conversation as resolved.
request_pad = "padrequest=" + ("b" * 1200)
config = make_m3u_rtsp_config(r2h_port, rtsp.port, "OverflowMerge", "?" + configured_pad)
r2h = R2HProcess(r2h_binary, r2h_port, config_content=config, capture_log=True)
r2h.start()
Expand Down
3 changes: 2 additions & 1 deletion src/configuration.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "configuration.h"
#include "epg.h"
#include "http.h"
#include "m3u.h"
#include "service.h"
#include "utils.h"
Expand All @@ -13,7 +14,7 @@
#include <string.h>
#include <strings.h>

#define MAX_LINE 1024
#define MAX_LINE 4096

/* GLOBAL */
config_t config;
Expand Down
4 changes: 2 additions & 2 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ int http_parse_url_components(const char *url, char *protocol, char *host, char

/* Extract path if present */
if (path_start && path) {
strncpy(path, path_start, 1023);
path[1023] = '\0';
strncpy(path, path_start, 2047);
path[2047] = '\0';
}

/* Parse host:port */
Expand Down
12 changes: 10 additions & 2 deletions src/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

#include <sys/types.h>

/* Maximum URL buffer size shared across the HTTP/RTSP pipeline.
* RTSP_SERVER_URL_SIZE, RTSP_SERVER_PATH_SIZE, and RTSP_URL_COPY_SIZE (rtsp.h)
* are sized to match. Keep all in sync to avoid silent mid-pipeline
* truncation. Compile-time override: -DHTTP_URL_BUFFER_SIZE=N */
#ifndef HTTP_URL_BUFFER_SIZE
#define HTTP_URL_BUFFER_SIZE 2048
#endif

/* Forward declaration */
typedef struct connection_s connection_t;

Expand All @@ -25,7 +33,7 @@ typedef enum { HTTP_PARSE_REQ_LINE = 0, HTTP_PARSE_HEADERS, HTTP_PARSE_BODY, HTT
/* HTTP request structure */
typedef struct {
char method[16];
char url[1024];
char url[HTTP_URL_BUFFER_SIZE];
char hostname[256];
char user_agent[256];
Comment thread
stackia marked this conversation as resolved.
char accept[256];
Expand Down Expand Up @@ -212,7 +220,7 @@ void http_send_401(connection_t *conn);
* @param port Output buffer for port (can be NULL), size should be at least 16
* bytes
* @param path Output buffer for path (can be NULL), size should be at least
* 1024 bytes
* 2048 bytes
Comment thread
stackia marked this conversation as resolved.
* @return 0 on success, -1 on error
*/
int http_parse_url_components(const char *url, char *protocol, char *host, char *port, char *path);
Expand Down
6 changes: 3 additions & 3 deletions src/rtsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@
/* RTSP server URL - complete RTSP URL. Kept in sync with HTTP_URL_BUFFER_SIZE
* (service.h) so the entire pipeline shares one URL ceiling and there is no
* silent mid-pipeline truncation. */
#define RTSP_SERVER_URL_SIZE 1024
#define RTSP_SERVER_URL_SIZE 2048

/* RTSP server hostname - DNS name or IP address */
#define RTSP_SERVER_HOST_SIZE 256

/* RTSP server path - path component of URL with query string. Same sizing
* rationale as RTSP_SERVER_URL_SIZE. */
#define RTSP_SERVER_PATH_SIZE 1024
#define RTSP_SERVER_PATH_SIZE 2048

#define RTSP_CREDENTIAL_SIZE 128

/* URL copy buffer - for URL parsing operations. Same sizing rationale as
* RTSP_SERVER_URL_SIZE. */
#define RTSP_URL_COPY_SIZE 1024
#define RTSP_URL_COPY_SIZE 2048

/* Time conversion buffers - for playseek time formatting */
#define RTSP_TIME_STRING_SIZE 64
Expand Down
10 changes: 0 additions & 10 deletions src/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

/* ========== HTTP/SERVICE BUFFER SIZE CONFIGURATION ========== */

/* HTTP URL working buffer - for URL manipulation. The query-merge path in
* service_create_with_query_merge() builds into this same buffer and then
* re-parses through service_create_from_*_url(), and the RTSP layer
* (RTSP_SERVER_URL_SIZE / RTSP_SERVER_PATH_SIZE / RTSP_URL_COPY_SIZE in
* rtsp.h) is sized to match. Keep all four in sync to avoid silent
* mid-pipeline truncation. */
#ifndef HTTP_URL_BUFFER_SIZE
#define HTTP_URL_BUFFER_SIZE 1024
#endif

/* HTTP URL component buffers - for parsing multicast URLs */
#ifndef HTTP_ADDR_COMPONENT_SIZE
#define HTTP_ADDR_COMPONENT_SIZE 256
Expand Down
Loading