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

Reimar Döffinger <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <[email protected]>
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

_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.