aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/decoder/flac_metadata.c3
-rw-r--r--src/decoder/flac_metadata.h3
3 files changed, 6 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 208ba1069..138630967 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
ver 0.16.4 (2010/??/??)
* decoder:
- ffmpeg: workaround for semantic API change in recent ffmpeg versions
+ - flac: validate the sample rate when scanning the tag
ver 0.16.3 (2011/06/04)
diff --git a/src/decoder/flac_metadata.c b/src/decoder/flac_metadata.c
index f2f2f954d..5b94fd426 100644
--- a/src/decoder/flac_metadata.c
+++ b/src/decoder/flac_metadata.c
@@ -224,7 +224,8 @@ flac_tag_apply_metadata(struct tag *tag, const char *track,
break;
case FLAC__METADATA_TYPE_STREAMINFO:
- tag->time = flac_duration(&block->data.stream_info);
+ if (block->data.stream_info.sample_rate > 0)
+ tag->time = flac_duration(&block->data.stream_info);
break;
default:
diff --git a/src/decoder/flac_metadata.h b/src/decoder/flac_metadata.h
index 06e691d1d..e52b0fb82 100644
--- a/src/decoder/flac_metadata.h
+++ b/src/decoder/flac_metadata.h
@@ -20,6 +20,7 @@
#ifndef MPD_FLAC_METADATA_H
#define MPD_FLAC_METADATA_H
+#include <assert.h>
#include <stdbool.h>
#include <FLAC/metadata.h>
@@ -29,6 +30,8 @@ struct replay_gain_info;
static inline unsigned
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
{
+ assert(stream_info->sample_rate > 0);
+
return (stream_info->total_samples + stream_info->sample_rate - 1) /
stream_info->sample_rate;
}