Skip to content

parse_ldif: keep the full length when joining folded lines - #574

Open
Ar-maan05 wants to merge 1 commit into
sudo-project:mainfrom
Ar-maan05:fix-ldif-multi-fold
Open

Ar-maan05 wants to merge 1 commit into
sudo-project:mainfrom
Ar-maan05:fix-ldif-multi-fold

Conversation

@Ar-maan05

Copy link
Copy Markdown

cvtsudoers -i ldif breaks on an attribute that is folded over three or more lines. With two lines it works:

sudoCommand: /usr/bin/sys
 temctl restart httpd

but split the same value once more:

sudoCommand: /usr/bin/sys
 temctl rest
 art httpd

and it fails:

before: cvtsudoers: invalid LDIF attribute: sudoCommandart httpd
after:  millert ALL = /usr/bin/systemctl restart httpd, /usr/bin/ls

After appending a continuation to the saved line, len still holds just the continuation's length. The next fold saves that as savedlen, so the third piece is copied over the middle of the line. This adds the saved length back to len after the append.

Added regress/cvtsudoers/test42.sh (and MANIFEST entries). It fails without the fix, and make -C plugins/sudoers check passes with it.

When a folded LDIF line was appended to the saved portion, len was left as the length of the continuation alone. A second continuation was then saved with that short length and copied over the middle of the attribute, so a value folded over three or more lines was corrupted, e.g. "sudoCommand: /usr/bin/sys", " temctl rest", " art httpd" became "sudoCommandart httpd" and was rejected as an invalid LDIF attribute.

Add the saved length to len after the append, and add a cvtsudoers regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant