1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Description: Fix two possible segfaults in file mode handling.
Forwarded: not-yet
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2015-09-15
--- a/mixlib/mix_file.c
+++ b/mixlib/mix_file.c
@@ -50,6 +50,9 @@
FILE *file;
const gchar *fmode = fmode_to_type_ (mode);
+ if (fmode == NULL)
+ return NULL;
+
/* if the read/write file already exists, open in r+ mode */
if (mode == mix_io_RDWRT && (file = fopen (name, "r")))
{
--- a/mixlib/xmix_io.h
+++ b/mixlib/xmix_io.h
@@ -35,7 +35,7 @@
extern const char * io_OPENTYPE_[5];
-#define fmode_to_type_(mode) ( (mode) < 6 ? io_OPENTYPE_[(mode)]:NULL )
+#define fmode_to_type_(mode) ( (mode) < (sizeof(io_OPENTYPE_) / sizeof(io_OPENTYPE_[0])) ? io_OPENTYPE_[(mode)]:NULL )
/* initialisation */
extern gboolean
|