#1051414 'ldapvi --in' issue with base64 encoded dn when (len_dn % 3) == 0

Package:
ldapvi
Source:
ldapvi
Description:
perform an LDAP search and update results using a text editor
Submitter:
ktetzl
Date:
2023-09-07 13:57:04 UTC
Severity:
normal
Tags:
#1051414#5
Date:
2023-09-07 12:08:18 UTC
From:
To:
'ldapvi --in' has a bug in ldapvi/base64.c read_base64(..) that cause a missing
'\0' terminator when decoding base64 encoded DNs which don't end with padding
(i.e. when (len_decoded_dn % 3) == 0).

Recipe to reproduce the issue:

Example LDIF file (test.ldif):
--
# dn of 'ou=abc,dc=example,dc=com' (length 24) gets base64 encoded
# without padding
dn:: b3U9YWJjLGRjPWV4YW1wbGUsZGM9Y29t
objectclass: organizationalUnit
ou: abc
--

Running:

    VISUAL=cat ldapvi --in --add test.ldif 2>/dev/null

results in the following output (note the 'sZGM9Y29t' suffix after 'add
ou=abc,dc=example,dc=com'):
--
# -*- coding: utf-8 -*- vim:fileencoding=utf-8:
# http://www.lichteblau.com/ldapvi/manual#syntax

add ou=abc,dc=example,dc=comsZGM9Y29t
objectclass: organizationalUnit
ou: abc
--