mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
streamts: don't overflow receive buffer, better diag message
Origin commit data
------------------
Commit: ec3201ab04
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2017-02-12 (Sun, 12 Feb 2017)
This commit is contained in:
@@ -371,9 +371,11 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro
|
|||||||
bp = &cbuf[0];
|
bp = &cbuf[0];
|
||||||
|
|
||||||
/* read one line */
|
/* read one line */
|
||||||
while (bp - &cbuf[0] < (int) sizeof(cbuf)) {
|
while (bp - &cbuf[0] < (int) sizeof(cbuf) - 1) {
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
int res = read(fd, &c, 1);
|
int res = read(fd, &c, 1);
|
||||||
|
if (res == 0)
|
||||||
|
break;
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
perror("read");
|
perror("read");
|
||||||
return false;
|
return false;
|
||||||
@@ -381,12 +383,11 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro
|
|||||||
if ((*bp++ = c) == '\n')
|
if ((*bp++ = c) == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*bp = 0;
|
||||||
|
|
||||||
*bp++ = 0;
|
printf("CStreamManager::Parse: got %d bytes '%s'", (int)(bp-&cbuf[0]), cbuf);
|
||||||
bp = &cbuf[0];
|
bp = &cbuf[0];
|
||||||
|
|
||||||
printf("CStreamManager::Parse: got %s\n", cbuf);
|
|
||||||
|
|
||||||
/* send response to http client */
|
/* send response to http client */
|
||||||
if (!strncmp(cbuf, "GET /", 5)) {
|
if (!strncmp(cbuf, "GET /", 5)) {
|
||||||
fprintf(fp, "HTTP/1.1 200 OK\r\nServer: streamts (%s)\r\n\r\n", "ts" /*&argv[1][1]*/);
|
fprintf(fp, "HTTP/1.1 200 OK\r\nServer: streamts (%s)\r\n\r\n", "ts" /*&argv[1][1]*/);
|
||||||
|
Reference in New Issue
Block a user