mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	modules: make sure we don't overrun our array
Limit the max number of params to 512 and make sure we don't collect more.
This commit is contained in:
		
							parent
							
								
									6cda416e71
								
							
						
					
					
						commit
						971bc8a249
					
				
					 1 changed files with 18 additions and 13 deletions
				
			
		| 
						 | 
					@ -898,12 +898,14 @@ static const struct pw_stream_events sink_events = {
 | 
				
			||||||
	.param_changed = output_param_changed
 | 
						.param_changed = output_param_changed
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MAX_PARAMS	512u
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int setup_streams(struct impl *impl)
 | 
					static int setup_streams(struct impl *impl)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	uint32_t n_params, i;
 | 
						uint32_t n_params, i;
 | 
				
			||||||
	uint32_t offsets[512];
 | 
						uint32_t offsets[MAX_PARAMS];
 | 
				
			||||||
	const struct spa_pod *params[512];
 | 
						const struct spa_pod *params[MAX_PARAMS];
 | 
				
			||||||
	struct spa_pod_dynamic_builder b;
 | 
						struct spa_pod_dynamic_builder b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->capture = pw_stream_new(impl->core,
 | 
						impl->capture = pw_stream_new(impl->core,
 | 
				
			||||||
| 
						 | 
					@ -953,17 +955,18 @@ static int setup_streams(struct impl *impl)
 | 
				
			||||||
	n_params = 0;
 | 
						n_params = 0;
 | 
				
			||||||
	spa_pod_dynamic_builder_init(&b, NULL, 0, 4096);
 | 
						spa_pod_dynamic_builder_init(&b, NULL, 0, 4096);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (n_params < MAX_PARAMS) {
 | 
				
			||||||
		offsets[n_params++] = b.b.state.offset;
 | 
							offsets[n_params++] = b.b.state.offset;
 | 
				
			||||||
		spa_format_audio_raw_build(&b.b, SPA_PARAM_EnumFormat, &impl->capture_info);
 | 
							spa_format_audio_raw_build(&b.b, SPA_PARAM_EnumFormat, &impl->capture_info);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	int nbr_of_external_props = spa_audio_aec_enum_props(impl->aec, 0, NULL);
 | 
						int nbr_of_external_props = spa_audio_aec_enum_props(impl->aec, 0, NULL);
 | 
				
			||||||
	if (nbr_of_external_props > 0) {
 | 
					 | 
				
			||||||
	for (int i = 0; i < nbr_of_external_props; i++) {
 | 
						for (int i = 0; i < nbr_of_external_props; i++) {
 | 
				
			||||||
 | 
							if (n_params < MAX_PARAMS) {
 | 
				
			||||||
			offsets[n_params++] = b.b.state.offset;
 | 
								offsets[n_params++] = b.b.state.offset;
 | 
				
			||||||
			spa_audio_aec_enum_props(impl->aec, i, &b.b);
 | 
								spa_audio_aec_enum_props(impl->aec, i, &b.b);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (n_params < MAX_PARAMS) {
 | 
				
			||||||
		offsets[n_params++] = b.b.state.offset;
 | 
							offsets[n_params++] = b.b.state.offset;
 | 
				
			||||||
		spa_pod_builder_add_object(&b.b,
 | 
							spa_pod_builder_add_object(&b.b,
 | 
				
			||||||
                                SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
 | 
					                                SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
 | 
				
			||||||
| 
						 | 
					@ -971,9 +974,11 @@ static int setup_streams(struct impl *impl)
 | 
				
			||||||
                                SPA_PROP_INFO_description, SPA_POD_String("Path to WAV file"),
 | 
					                                SPA_PROP_INFO_description, SPA_POD_String("Path to WAV file"),
 | 
				
			||||||
                                SPA_PROP_INFO_type, SPA_POD_String(impl->wav_path),
 | 
					                                SPA_PROP_INFO_type, SPA_POD_String(impl->wav_path),
 | 
				
			||||||
                                SPA_PROP_INFO_params, SPA_POD_Bool(true));
 | 
					                                SPA_PROP_INFO_params, SPA_POD_Bool(true));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (n_params < MAX_PARAMS) {
 | 
				
			||||||
		offsets[n_params++] = b.b.state.offset;
 | 
							offsets[n_params++] = b.b.state.offset;
 | 
				
			||||||
		get_props_param(impl, &b.b);
 | 
							get_props_param(impl, &b.b);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < n_params; i++)
 | 
						for (i = 0; i < n_params; i++)
 | 
				
			||||||
		params[i] = spa_pod_builder_deref(&b.b, offsets[i]);
 | 
							params[i] = spa_pod_builder_deref(&b.b, offsets[i]);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue