netfile: paranoia checks to avoid out-of-bounds access

This commit is contained in:
Stefan Seyfried
2013-05-28 14:29:53 +02:00
committed by Jacek Jendrzej
parent b8aa68a2da
commit 256aacf33f

View File

@@ -2,7 +2,7 @@
| Neutrino-GUI - DBoxII-Project | Neutrino-GUI - DBoxII-Project
| |
| Copyright (C) 2004 by Sanaia <sanaia at freenet dot de> | Copyright (C) 2004 by Sanaia <sanaia at freenet dot de>
| Copyright (C) 2010-2012 Stefan Seyfried | Copyright (C) 2010-2013 Stefan Seyfried
| |
| netfile - remote file access mapper | netfile - remote file access mapper
| |
@@ -421,6 +421,9 @@ int request_file(URL *url)
if(meta_int) if(meta_int)
{ {
if (slot < 0){
dprintf(stderr, "error: meta_int != 0 && slot < 0");
}else{
/* hook in the filter function if there is meta */ /* hook in the filter function if there is meta */
/* data present in the stream */ /* data present in the stream */
cache[slot].filter_arg = ShoutCAST_InitFilter(meta_int); cache[slot].filter_arg = ShoutCAST_InitFilter(meta_int);
@@ -432,6 +435,7 @@ int request_file(URL *url)
if(cache[slot].filter_arg->state) if(cache[slot].filter_arg->state)
memmove(cache[slot].filter_arg->state, &tmp, sizeof(CSTATE)); memmove(cache[slot].filter_arg->state, &tmp, sizeof(CSTATE));
} }
}
/* push the created ID3 header into the stream cache */ /* push the created ID3 header into the stream cache */
push(url->stream, (char*)&id3, id3.len); push(url->stream, (char*)&id3, id3.len);
@@ -1673,6 +1677,8 @@ int f_status(FILE *stream, void (*cb)(void*))
/* lookup the stream ID in the cache table */ /* lookup the stream ID in the cache table */
i = getCacheSlot(stream); i = getCacheSlot(stream);
if (i < 0)
return -1;
if(cache[i].fd == stream) if(cache[i].fd == stream)
{ {