uutils / uutils/coreutils

base64: Unexpected result when decoding data with garbage

Open
#12,923 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

U - base64
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

Hi,
I have run in to a problem when trying to base64 decode a file that contains garbage data. This is with the coreutils version 0.8.0, installed from the Ubuntu 26.04 Resolute apt repository.

Consider the following truncated content from my_base64_file.txt:
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMjQ5MmF

Yes! It contains a ., which is garbage. I know.

When decoding it with base64 (GNU coreutils) 9.4 the result is:
base64 -d my_base64_file.txt --> {"alg":"RS256","typ":"JWT"}base64: invalid input
base64 -di my_base64_file.txt --> {"alg":"RS256","typ":"JWT"}{"jti":"c2492abase64: invalid input

But, with base64 (core uutils 0.8.0) I get:
base64 -d my_base64_file.txt --> base64: error: invalid input
base64 -di my_base64_file.txt --> base64: error: invalid input

Is there something I am missing here, or is there a bug with the --ignore-garbage feature?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the documented base64 -d and base64 -di commands with the provided input, then trace the base64 command's --ignore-garbage handling. Done means the behavior matches the reported GNU coreutils results, including decoded output and the invalid-input diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.