Skip to content

base64: Unexpected result when decoding data with garbage #12923

Description

@EmilSodergren

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions