aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-09 15:30:25 +0200
committerChristian Grothoff <christian@grothoff.org>2017-10-09 15:30:25 +0200
commitb577d5452c5c4ee9d552da62a24b95f461551fe2 (patch)
tree1b929fc9e3020f6a12fbda57a51c23fc1b70f259
parentf376d245006575e260c76aa899d735f30816f5b7 (diff)
downloadlibextractor-b577d5452c5c4ee9d552da62a24b95f461551fe2.tar.gz
libextractor-b577d5452c5c4ee9d552da62a24b95f461551fe2.zip
fix SIGFPE in wav plugin found by Leon Zhao
-rw-r--r--ChangeLog3
-rw-r--r--src/plugins/wav_extractor.c10
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e432be..313f54b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
1Mon Oct 9 15:30:01 CEST 2017
2 Fix SIGFPE in WAV plugin found by Leon Zhao. -CG
3
1Sun Apr 30 01:50:01 CEST 2017 4Sun Apr 30 01:50:01 CEST 2017
2 Updating French translation. -SA 5 Updating French translation. -SA
3 6
diff --git a/src/plugins/wav_extractor.c b/src/plugins/wav_extractor.c
index 45d3d52..dae8890 100644
--- a/src/plugins/wav_extractor.c
+++ b/src/plugins/wav_extractor.c
@@ -49,7 +49,7 @@ little_endian_to_host32 (uint32_t in)
49{ 49{
50 unsigned char *ptr = (unsigned char *) &in; 50 unsigned char *ptr = (unsigned char *) &in;
51 51
52 return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) | 52 return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) |
53 ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); 53 ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF);
54} 54}
55#endif 55#endif
@@ -81,7 +81,7 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec)
81 uint32_t samples; 81 uint32_t samples;
82 char scratch[256]; 82 char scratch[256];
83 83
84 if (44 > 84 if (44 >
85 ec->read (ec->cls, &data, 44)) 85 ec->read (ec->cls, &data, 44))
86 return; 86 return;
87 buf = data; 87 buf = data;
@@ -109,6 +109,8 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec)
109 return; /* invalid sample size found in wav file */ 109 return; /* invalid sample size found in wav file */
110 if (0 == channels) 110 if (0 == channels)
111 return; /* invalid channels value -- avoid division by 0! */ 111 return; /* invalid channels value -- avoid division by 0! */
112 if (0 == sample_rate)
113 return; /* invalid sample_rate */
112 samples = data_len / (channels * (sample_size >> 3)); 114 samples = data_len / (channels * (sample_size >> 3));
113 115
114 snprintf (scratch, 116 snprintf (scratch,
@@ -118,7 +120,7 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec)
118 ? (samples * 1000 / sample_rate) 120 ? (samples * 1000 / sample_rate)
119 : (samples / sample_rate) * 1000, 121 : (samples / sample_rate) * 1000,
120 sample_rate, (1 == channels) ? _("mono") : _("stereo")); 122 sample_rate, (1 == channels) ? _("mono") : _("stereo"));
121 if (0 != ec->proc (ec->cls, 123 if (0 != ec->proc (ec->cls,
122 "wav", 124 "wav",
123 EXTRACTOR_METATYPE_RESOURCE_TYPE, 125 EXTRACTOR_METATYPE_RESOURCE_TYPE,
124 EXTRACTOR_METAFORMAT_UTF8, 126 EXTRACTOR_METAFORMAT_UTF8,
@@ -126,7 +128,7 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec)
126 scratch, 128 scratch,
127 strlen (scratch) + 1)) 129 strlen (scratch) + 1))
128 return; 130 return;
129 if (0 != ec->proc (ec->cls, 131 if (0 != ec->proc (ec->cls,
130 "wav", 132 "wav",
131 EXTRACTOR_METATYPE_MIMETYPE, 133 EXTRACTOR_METATYPE_MIMETYPE,
132 EXTRACTOR_METAFORMAT_UTF8, 134 EXTRACTOR_METAFORMAT_UTF8,