Skip to content

Commit

Permalink
base64: line does not end with newline
Browse files Browse the repository at this point in the history
  • Loading branch information
aklomp committed Jan 28, 2024
1 parent 6f52aaa commit 78b7a84
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bin/base64.c
Expand Up @@ -247,12 +247,11 @@ static bool
write_wrapped (const struct config *config, char *buf, size_t len)
{
static size_t col = 0;
static char nl = '\x00';

// Special case: if buf is NULL, print final trailing newline.
if (buf == NULL) {
if (config->wrap > 0 && col > 0) {
return write_stdout(config, &nl, 1);
return write_stdout(config, "\n ", 2);
}
return true;
}
Expand Down Expand Up @@ -288,7 +287,7 @@ write_wrapped (const struct config *config, char *buf, size_t len)

// If the line is full, append a newline.
if (col == config->wrap) {
if (iov_append(config, iov, &nvec, &nl, 1) == false) {
if (iov_append(config, iov, &nvec, "\n ", 2) == false) {
return false;
}
col = 0;
Expand Down

0 comments on commit 78b7a84

Please sign in to comment.