]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_prometheus: Clone containers before iterating
authorGeorge Joseph <gjoseph@digium.com>
Thu, 1 Apr 2021 13:39:03 +0000 (07:39 -0600)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Fri, 2 Apr 2021 12:37:41 +0000 (07:37 -0500)
commit53c702e1cc1f2d355ae3710730872fc30622057e
tree9c0d2c046a86254b32046d504a3e5b1959a3c00c
parent46ed6af9c29261232ced72196fd1cad942ce5a0a
res_prometheus: Clone containers before iterating

The channels, bridges and endpoints scrape functions were
grabbing their respective global containers, getting the
count of entries, allocating metric arrays based on
that count, then iterating over the container.  If the
global container had new objects added after the count
was taken and the metric arrays were allocated, we'd run
out of metric entries and attempt to write past the end
of the arrays.

Now each of the scape functions clone their respective
global containers and all operations are done on the
clone.  Since the clone is stable between getting the
count and iterating over it, we can't run past the end
of the metrics array.

ASTERISK-29130
Reported-By: Francisco Correia
Reported-By: BJ Weschke
Reported-By: Sébastien Duthil
Change-Id: If0c8e40853bc0e9429f2ba9c7f5f358d90c311af
res/prometheus/bridges.c
res/prometheus/channels.c
res/prometheus/endpoints.c