Home GnuPG

sexp: Fix broken gcry_sexp_nth.
cbdc355415f8Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

sexp: Fix broken gcry_sexp_nth.

* src/sexp.c (_gcry_sexp_nth): Return a valid S-expression for a data
element.
(NODE): Remove unused typedef.
(ST_HINT): Comment unused macro.
* tests/t-sexp.c (bug_1594): New.
(main): Run new test.

Before 1.6.0 gcry_sexp_nth (list, 0) with a LIST of "(a (b 3:pqr) (c
3:456) (d 3:xyz))" returned the entire list. 1.6.0 instead returned
NULL. However, this is also surprising and the expected value would
be "(a)". This patch fixes this.

Somewhat related to that gcry_sexp_nth returned a broken list if
requesting index 1 of a list like "(n foo)". It returned just the
"foo" but not as a list which is required by the S-expression specs.
Due to this patch the returned value is now "(foo)".

Thanks to Ludovic Courtès for pointing out these problems.

Details

Provenance
wernerAuthored on Jan 9 2014, 7:14 PM
Parents
rC7460e9243b3c: tests: Improve t-common.h.
Branches
Unknown
Tags
Unknown

Event Timeline

Werner Koch <wk@gnupg.org> committed rCcbdc355415f8: sexp: Fix broken gcry_sexp_nth. (authored by Werner Koch <wk@gnupg.org>).Jan 28 2014, 12:52 PM
werner mentioned this in Unknown Object (Maniphest Task).Mar 27 2017, 5:05 PM
werner mentioned this in Unknown Object (Maniphest Task).Mar 27 2017, 5:28 PM