ks: Add check for circular reference
When adding a circular reference via `override`
```sh
kdb meta-set "spec:/circular" "override/#0" "/circular"
```
the lookup resulted in a segfault (stack overflow). To prevent this, a
check has been added to make sure that the linked key differs from the
key currently being looked up.
@@ -1970,6 +1970,12 @@ static Key * elektraLookupBySpecLinks (KeySet * ks, Key * specKey, char * buffer
}
else
keySetName (k, keyString (m));
+ // circular reference: abort
+ if (!strcmp (keyName (specKey), keyName (k)))
+ {
+ ret = NULL;
+ break;
+ }
ret = ksLookup (ks, k, KDB_O_NODEFAULT);
if (ret) break;
++i;
