[2/3] glibcymbols.read_abilist: Add check for duplicate symbols
Commit Message
This detects some bogus abilist files.
---
scripts/glibcsymbols.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
On 12/03/2021 05:23, Florian Weimer via Libc-alpha wrote:
> This detects some bogus abilist files.
> ---
> scripts/glibcsymbols.py | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/glibcsymbols.py b/scripts/glibcsymbols.py
> index e329ead7f2..1bdd19e51e 100644
> --- a/scripts/glibcsymbols.py
> +++ b/scripts/glibcsymbols.py
> @@ -63,7 +63,10 @@ def read_abilist(path):
> with open(path) as inp:
> for line in inp:
> version, symbol, flags = line.strip().split(' ', 2)
> - result[VersionedSymbol(symbol, version)] = flags
> + versym = VersionedSymbol(symbol, version)
> + if versym in result:
> + raise IOError("{}: duplicate symbol {}".format(path, versym))
> + result[versym] = flags
> return result
>
> def abilist_lines(symbols):
>
@@ -63,7 +63,10 @@ def read_abilist(path):
with open(path) as inp:
for line in inp:
version, symbol, flags = line.strip().split(' ', 2)
- result[VersionedSymbol(symbol, version)] = flags
+ versym = VersionedSymbol(symbol, version)
+ if versym in result:
+ raise IOError("{}: duplicate symbol {}".format(path, versym))
+ result[versym] = flags
return result
def abilist_lines(symbols):