Package: toolame Version: 02l-6 Severity: important Tags: patch When reading the sample frequency of the WAV header (a 32-bit value), a pointer to an "unsigned long" is used on little-endian platforms. Unfortunately, "unsigned long" is 64-bit on 64-bit platforms:
% file audio.wav audio.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 48000 Hz % toolame -s 48 audio.wav Parsing Wave File Header >>> Unknown samp freq 824633720880000 Hz in Wave Header >>> Default 44.1 kHz samp freq selected >>> Input Wave File is Stereo -------------------------------------------- Input File : 'audio.wav' 44.1 kHz Output File: 'audio.mp2' 192 kbps MPEG-1 Layer II j-stereo Psy model 1 [De-emph:Off Copyright:No Original:No CRC:Off] [Padding:Normal Byte-swap:Off Chanswap:Off DAB:Off] ATH adjustment 0.000000 -------------------------------------------- (...) (note that 824633720880000 & 0xFFFFFFFF == 48000) I patched it using a uint32_t to be sure of the length: % ./toolame-02l/toolame -s 48 audio.wav Parsing Wave File Header >>> 48000 Hz sampling freq selected >>> Input Wave File is Stereo -------------------------------------------- Input File : 'audio.wav' 48.0 kHz Output File: 'audio.mp2' 192 kbps MPEG-1 Layer II j-stereo Psy model 1 [De-emph:Off Copyright:No Original:No CRC:Off] [Padding:Normal Byte-swap:Off Chanswap:Off DAB:Off] ATH adjustment 0.000000 -------------------------------------------- (...) Best regards, -Christian -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.26.5-mooch.1-amd64 (SMP w/2 CPU cores; PREEMPT) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF8) Shell: /bin/sh linked to /bin/bash Versions of packages toolame depends on: ii libc6 2.7-15 GNU C Library: Shared libraries toolame recommends no packages. toolame suggests no packages. -- no debconf information
diff -Nru toolame-02l.orig/audio_read.c toolame-02l/audio_read.c --- toolame-02l.orig/audio_read.c 2008-11-02 19:01:25.000000000 +0100 +++ toolame-02l/audio_read.c 2008-11-02 19:09:57.000000000 +0100 @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdint.h> #include "common.h" #include "encoder.h" #include "options.h" @@ -329,7 +330,7 @@ } } if (NativeByteOrder == order_littleEndian) { - samplerate = *(unsigned long *) (&wave_header_buffer[24]); + samplerate = *(uint32_t *) (&wave_header_buffer[24]); } else { samplerate = wave_header_buffer[27] + (wave_header_buffer[26] << 8) +