]> git.ipfire.org Git - thirdparty/freeradius-server.git/commit
don't let the user delete attributes we're looping over
authorAlan T. DeKok <aland@freeradius.org>
Mon, 2 Sep 2024 12:22:36 +0000 (08:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 2 Sep 2024 12:23:06 +0000 (08:23 -0400)
commite2a12dcbac4d7651f8102447696db50558d82e5a
tree98804fbfd908decadca28cd31854a24ea2e21065
parent3bccf7a70e7cc602a9a2646b538355c8f1cb3ef3
don't let the user delete attributes we're looping over

this isn't perfect, but it's good enough.

It can still crash if the user has one "foreach" loop nested
inside of another one, AND both loop over the same attributes,
AND a variable is deleted after the inner "foreach" loop is run.

The general answer then is "don't do that".

We could fix this by using the old way of copying all of the VPs,
looping over the copy, and then moving the copy back in place of
the original VPs.  But that process is expensive, and almost always
not needed.

For now, it's simpler to just say "don't modify the attributes
you're looping over"
src/lib/unlang/foreach.c
src/lib/util/pair.h
src/lib/util/value.h
src/tests/keywords/foreach-delete [new file with mode: 0644]