SALSA-Lib: snd_pcm_hw_params_any clobbers memory
Dear list,
Using SALSA-Lib 0.0.2, I call
snd_pcm_open
snd_pcm_hw_params_malloc
snd_pcm_hw_params_any
The call to snd_pcm_hw_params_any appears to clobber memory beyond the end of the hw_params allocated by snd_pcm_hw_params_malloc (as reported by linking in -lmcheck).
The code is being cross-compiled and tested on an ARM processor
(PXA270) which is running linux kernel 2.6.21. This same code sequence
-does- operate properly (in the same ARM test environment) when compiled against AlsaLib 1.0.13.
I got "lost" somewhere around the hw_refine IOCTL .... Any suggestions appreciated :)
Thanks, Scott.
At Wed, 27 Jun 2007 16:33:52 -0400,
Quoted 11 lines · J. Scott Merritt
Dear list,
Using SALSA-Lib 0.0.2, I call
snd_pcm_open
snd_pcm_hw_params_malloc
snd_pcm_hw_params_anyThe call to
snd_pcm_hw_params_anyappears to clobber memory beyond the end of thehw_paramsallocated bysnd_pcm_hw_params_malloc(as reported by linking in -lmcheck).
Gosh, my bad. I didn't test *_malloc() at all.
There was a stupid bug in the template I copy-n-pasted. The fix patch is below. I'll release version 0.0.3 soon later.
Thanks for reporting!
Takashi
src/ctl_macros.h +6 -6
@@ -305,7 +305,7 @@ static inlinestatic inline int snd_ctl_elem_id_malloc (snd_ctl_elem_id_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -411,7 +411,7 @@ static inlinestatic inline int snd_ctl_card_info_malloc (snd_ctl_card_info_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -487,7 +487,7 @@ static inlinestatic inline int snd_ctl_event_malloc (snd_ctl_event_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -526,7 +526,7 @@ static inlinestatic inline int snd_ctl_elem_list_malloc (snd_ctl_elem_list_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -627,7 +627,7 @@ static inlinestatic inline int snd_ctl_elem_info_malloc (snd_ctl_elem_info_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -912,7 +912,7 @@ static inlinestatic inline int snd_ctl_elem_value_malloc (snd_ctl_elem_value_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
src/hwdep_macros.h +3 -3
@@ -107,7 +107,7 @@ static inlinestatic inline int snd_hwdep_info_malloc (snd_hwdep_info_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -170,7 +170,7 @@ static inlinestatic inline int snd_hwdep_dsp_status_malloc (snd_hwdep_dsp_status_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -228,7 +228,7 @@ static inlinestatic inline int snd_hwdep_dsp_image_malloc (snd_hwdep_dsp_image_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
src/mixer_macros.h +1 -1
@@ -518,7 +518,7 @@ static inlinestatic inline int snd_mixer_selem_id_malloc (snd_mixer_selem_id_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
src/pcm_macros.h +7 -7
@@ -599,7 +599,7 @@ static inlinestatic inline int snd_pcm_access_mask_malloc (snd_pcm_access_mask_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -663,7 +663,7 @@ static inlinestatic inline int snd_pcm_format_mask_malloc (snd_pcm_format_mask_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -727,7 +727,7 @@ static inlinestatic inline int snd_pcm_subformat_mask_malloc (snd_pcm_subformat_mask_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -795,7 +795,7 @@ static inlinestatic inline int snd_pcm_hw_params_malloc (snd_pcm_hw_params_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -1770,7 +1770,7 @@ static inlinestatic inline int snd_pcm_sw_params_malloc (snd_pcm_sw_params_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -1940,7 +1940,7 @@ static inlinestatic inline int snd_pcm_status_malloc (snd_pcm_status_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -2025,7 +2025,7 @@ static inlinestatic inline int snd_pcm_info_malloc (snd_pcm_info_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
src/rawmidi_macros.h +3 -3
@@ -77,7 +77,7 @@ static inlinestatic inline int snd_rawmidi_info_malloc (snd_rawmidi_info_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!ptr)return -ENOMEM ;return 0 ;
@@ -193,7 +193,7 @@ static inlinestatic inline int snd_rawmidi_params_malloc (snd_rawmidi_params_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!ptr)return -ENOMEM ;return 0 ;
@@ -283,7 +283,7 @@ static inlinestatic inline int snd_rawmidi_status_malloc (snd_rawmidi_status_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!ptr)return -ENOMEM ;return 0 ;
src/timer_macros.h +5 -5
@@ -124,7 +124,7 @@ static inlinestatic inline int snd_timer_id_malloc (snd_timer_id_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -211,7 +211,7 @@ static inlinestatic inline int snd_timer_ginfo_malloc (snd_timer_ginfo_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -299,7 +299,7 @@ static inlinestatic inline int snd_timer_info_malloc (snd_timer_info_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -356,7 +356,7 @@ static inlinestatic inline int snd_timer_params_malloc (snd_timer_params_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
@@ -472,7 +472,7 @@ static inlinestatic inline int snd_timer_status_malloc (snd_timer_status_t **ptr) { - *ptr =calloc (1 ,sizeof (*ptr)); + *ptr =calloc (1 ,sizeof (**ptr));if (!*ptr)return -ENOMEM ;return 0 ;
Quoted 16 lines · On Thu, 28 Jun 2007 13:23:28 +0200 Takashi Iwai <[email protected]> wrote:
At Wed, 27 Jun 2007 16:33:52 -0400,
Quoted 11 lines · J. Scott Merritt
Dear list,
Using SALSA-Lib 0.0.2, I call
snd_pcm_open
snd_pcm_hw_params_malloc
snd_pcm_hw_params_anyThe call to
snd_pcm_hw_params_anyappears to clobber memory beyond the end of thehw_paramsallocated bysnd_pcm_hw_params_malloc(as reported by linking in -lmcheck).Gosh, my bad. I didn't test
*_malloc()at all.
Quoted 7 lines
There was a stupid bug in the template I copy-n-pasted. The fix patch is below. I'll release version 0.0.3 soon later.
Thanks for reporting!
Takashi
Problem resolved in SALSA-Lib 0.0.3 - thanks :)
(subsequent problem reported in new thread)