Fix use of uninitialized afhi->header_len.
authorAndre Noll <maan@systemlinux.org>
Wed, 19 Mar 2008 20:51:46 +0000 (21:51 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 19 Mar 2008 20:51:46 +0000 (21:51 +0100)
In aft's add_one_audio_file() we set the header len and
the header offset to zero so that the get_file_info()
functions of the audio format handlers that do not use
headers don't need to zero these fields.

However, this is not the right place to do that as para_afh
also calls get_file_info() via compute_afhi() but missed to
clear these fields which leads to a segmentation fault.

Fix this bug by moving the zeroing to compute_afhi().

afh_common.c
aft.c

index 4f84334c8486d48aee712f6099fd72e847b78af5..feee4c8d3dc14b492a65271daa5cffd9a90e93a5 100644 (file)
@@ -143,7 +143,11 @@ int guess_audio_format(const char *name)
 int compute_afhi(const char *path, char *data, size_t size,
                struct afh_info *afhi)
 {
 int compute_afhi(const char *path, char *data, size_t size,
                struct afh_info *afhi)
 {
-       int ret, i, format = guess_audio_format(path);
+       int ret, i, format;
+
+       afhi->header_offset = 0;
+       afhi->header_len = 0;
+       format = guess_audio_format(path);
 
        if (format >= 0) {
                ret = afl[format].get_file_info(data, size, afhi);
 
        if (format >= 0) {
                ret = afl[format].get_file_info(data, size, afhi);
diff --git a/aft.c b/aft.c
index 5f5548f03dc9e71989fddf41acb4cb16b568910c..51e36c8e7de190028e9b963c7fbd054d1aabd234 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1722,8 +1722,6 @@ static int add_one_audio_file(const char *path, const void *private_data)
        struct osl_object map, obj = {.data = NULL}, query, result = {.data = NULL};
        HASH_TYPE hash[HASH_SIZE];
 
        struct osl_object map, obj = {.data = NULL}, query, result = {.data = NULL};
        HASH_TYPE hash[HASH_SIZE];
 
-       afhi.header_offset = 0;
-       afhi.header_len = 0;
        ret = guess_audio_format(path);
        if (ret < 0 && !(pad->flags & ADD_FLAG_ALL))
                goto out_free;
        ret = guess_audio_format(path);
        if (ret < 0 && !(pad->flags & ADD_FLAG_ALL))
                goto out_free;