* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
#endif
#include <vlc_common.h>
+#include <vlc_memory.h>
#include "rtsp.h"
#include "real.h"
#define LE_32C(x,y) do {uint32_t in=y; *(uint32_t *)(x)=GetDWLE(&in);} while(0)
#define MAX(x,y) ((x>y) ? x : y)
-
static void hash(char *field, char *param)
{
uint32_t a, b, c, d;
}
}
-void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) {
+static void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) {
int ch_len, resp_len;
int i;
chksum[i] = response[i*4];
}
+#define MLTI_BUF_MAX_SIZE 2048
/*
* takes a MLTI-Chunk and a rule number got from match_asm_rule,
||(mlti_chunk[3] != 'I'))
{
lprintf("MLTI tag not detected, copying data\n");
- memcpy(*out, mlti_chunk, mlti_size);
+ memcpy(*out, mlti_chunk, __MIN(mlti_size,MLTI_BUF_MAX_SIZE));
return mlti_size;
}
}
size=BE_32(mlti_chunk);
- memcpy(*out, mlti_chunk+4, size);
+ memcpy(*out, mlti_chunk+4, __MIN(size,MLTI_BUF_MAX_SIZE));
return size;
}
* looking at stream description.
*/
-rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidth) {
+static rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidth) {
sdpplin_t *desc = NULL;
rmff_header_t *header = NULL;
desc=sdpplin_parse(data);
if( !desc ) return NULL;
- buf= (char *)malloc(2048);
+ buf= (char *)malloc(MLTI_BUF_MAX_SIZE);
if( !buf ) goto error;
header = calloc( 1, sizeof(rmff_header_t) );
int n;
rmff_dump_pheader(ph, (char*)*buffer);
+ if (ph->length<12) return 0;
n=rtsp_read_data(rtsp_session, (uint8_t*)(*buffer + 12), ph->length - 12);
return (n <= 0) ? 0 : n+12;
}
/* setup our streams */
real_calc_response_and_checksum (challenge2, checksum, challenge1);
- buf = realloc(buf, strlen(challenge2) + strlen(checksum) + 32);
+ buf = realloc_or_free(buf, strlen(challenge2) + strlen(checksum) + 32);
+ if( !buf ) goto error;
sprintf(buf, "RealChallenge2: %s, sd=%s", challenge2, checksum);
rtsp_schedule_field(rtsp_session, buf);
- buf = realloc(buf, strlen(session_id) + 32);
+ buf = realloc_or_free(buf, strlen(session_id) + 32);
+ if( !buf ) goto error;
sprintf(buf, "If-Match: %s", session_id);
rtsp_schedule_field(rtsp_session, buf);
rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
- buf = realloc(buf, strlen(mrl) + 32);
+ buf = realloc_or_free(buf, strlen(mrl) + 32);
+ if( !buf ) goto error;
sprintf(buf, "%s/streamid=0", mrl);
rtsp_request_setup(rtsp_session,buf);
if (h->prop->num_streams > 1) {
rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
- buf = realloc(buf, strlen(session_id) + 32);
+ buf = realloc_or_free(buf, strlen(session_id) + 32);
+ if( !buf ) goto error;
sprintf(buf, "If-Match: %s", session_id);
rtsp_schedule_field(rtsp_session, buf);
- buf = realloc(buf, strlen(mrl) + 32);
+ buf = realloc_or_free(buf, strlen(mrl) + 32);
+ if( !buf ) goto error;
sprintf(buf, "%s/streamid=1", mrl);
rtsp_request_setup(rtsp_session,buf);
}