mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: improve param result handling
Check if we actually managed to add the param to the builder before we try to deref it. Use a safer deref that checks the sizes of the pod and builder.
This commit is contained in:
		
							parent
							
								
									c54f64cd13
								
							
						
					
					
						commit
						f9d8bdb9b8
					
				
					 2 changed files with 6 additions and 4 deletions
				
			
		| 
						 | 
					@ -45,9 +45,10 @@ static inline void spa_result_func_device_params(void *data, int seq, int res,
 | 
				
			||||||
	const struct spa_result_device_params *r =
 | 
						const struct spa_result_device_params *r =
 | 
				
			||||||
		(const struct spa_result_device_params *)result;
 | 
							(const struct spa_result_device_params *)result;
 | 
				
			||||||
	uint32_t offset = d->builder->state.offset;
 | 
						uint32_t offset = d->builder->state.offset;
 | 
				
			||||||
	spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param));
 | 
						if (spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param)) < 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	d->data.next = r->next;
 | 
						d->data.next = r->next;
 | 
				
			||||||
	d->data.param = SPA_PTROFF(d->builder->data, offset, struct spa_pod);
 | 
						d->data.param = spa_pod_builder_deref(d->builder, offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline int spa_device_enum_params_sync(struct spa_device *device,
 | 
					static inline int spa_device_enum_params_sync(struct spa_device *device,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,9 +51,10 @@ static inline void spa_result_func_node_params(void *data,
 | 
				
			||||||
	const struct spa_result_node_params *r =
 | 
						const struct spa_result_node_params *r =
 | 
				
			||||||
		(const struct spa_result_node_params *) result;
 | 
							(const struct spa_result_node_params *) result;
 | 
				
			||||||
	uint32_t offset = d->builder->state.offset;
 | 
						uint32_t offset = d->builder->state.offset;
 | 
				
			||||||
	spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param));
 | 
						if (spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param)) < 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	d->data.next = r->next;
 | 
						d->data.next = r->next;
 | 
				
			||||||
	d->data.param = SPA_PTROFF(d->builder->data, offset, struct spa_pod);
 | 
						d->data.param = spa_pod_builder_deref(d->builder, offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline int spa_node_enum_params_sync(struct spa_node *node,
 | 
					static inline int spa_node_enum_params_sync(struct spa_node *node,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue