[MPlayer-dev-eng] [PATCH 3/6] stream.h: Abort on read length < 0.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Jan 18 00:00:37 EET 2021


If that happens something seriously went wrong
in the calling code and it's safer to not
continue.
This would have helped for e.g. trac #2360.
---
 stream/stream.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/stream/stream.h b/stream/stream.h
index b7c7abd03..3063684d0 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -23,6 +23,7 @@
 #include "m_option.h"
 #include "mp_msg.h"
 #include "url.h"
+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <inttypes.h>
@@ -283,6 +284,7 @@ static inline unsigned int stream_read_int24(stream_t *s)
 static inline int stream_read(stream_t *s, char *mem, int total)
 {
   int len=total;
+  if (total < 0) abort();
   while(len>0){
     int x;
     x=s->buf_len-s->buf_pos;
--
2.30.0



More information about the MPlayer-dev-eng mailing list