summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_mod.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_mod.c')
-rw-r--r--src/demuxers/demux_mod.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/demuxers/demux_mod.c b/src/demuxers/demux_mod.c
index e7c6f86b3..34b8ebabe 100644
--- a/src/demuxers/demux_mod.c
+++ b/src/demuxers/demux_mod.c
@@ -73,7 +73,7 @@ typedef struct {
char *title;
char *artist;
char *copyright;
- off_t filesize;
+ size_t filesize;
char *buffer;
@@ -130,11 +130,22 @@ static int probe_mod_file(demux_mod_t *this) {
/* returns 1 if the MOD file was opened successfully, 0 otherwise */
static int open_mod_file(demux_mod_t *this) {
int total_read;
+ off_t input_length;
/* Get size and create buffer */
- this->filesize = this->input->get_length(this->input);
+ input_length = this->input->get_length(this->input);
+ /* Avoid potential issues with signed variables and e.g. read() returning -1 */
+ if (input_length > 0x7FFFFFFF || input_length < 0) {
+ xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - size overflow\n");
+ return 0;
+ }
+ this->filesize = input_length;
this->buffer = (char *)malloc(this->filesize);
-
+ if(!this->buffer) {
+ xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - allocation failure\n");
+ return 0;
+ }
+
/* Seek to beginning */
this->input->seek(this->input, 0, SEEK_SET);
@@ -305,7 +316,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_mod_t));
+ this = calloc(1, sizeof(demux_mod_t));
this->stream = stream;
this->input = input;
@@ -368,7 +379,19 @@ static const char *get_extensions (demux_class_t *this_gen) {
}
static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
+ return "audio/x-mod: mod: SoundTracker/NoiseTracker/ProTracker Module;"
+ "audio/mod: mod: SoundTracker/NoiseTracker/ProTracker Module;"
+ "audio/it: it: ImpulseTracker Module;"
+ "audio/x-it: it: ImpulseTracker Module;"
+ "audio/x-stm: stm: ScreamTracker 2 Module;"
+ "audio/x-s3m: s3m: ScreamTracker 3 Module;"
+ "audio/s3m: s3m: ScreamTracker 3 Module;"
+ "application/playerpro: 669: 669 Tracker Module;"
+ "application/adrift: amf: ADRIFT Module File;"
+ "audio/med: med: Amiga MED/OctaMED Tracker Module Sound File;"
+ "audio/x-amf: amf: ADRIFT Module File;"
+ "audio/x-xm: xm: FastTracker II Audio;"
+ "audio/xm: xm: FastTracker II Audio;";
}
static void class_dispose (demux_class_t *this_gen) {
@@ -380,7 +403,7 @@ static void class_dispose (demux_class_t *this_gen) {
void *demux_mod_init_plugin (xine_t *xine, void *data) {
demux_mod_class_t *this;
- this = xine_xmalloc (sizeof (demux_mod_class_t));
+ this = calloc(1, sizeof(demux_mod_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;