Skip to content

Should handle upper-case checksums #774

Description

@hadess

Using flatpak-builder as available today on Flathub

The following source snippet:

      # OpenMeshCraft
      # https://github.com/bambulab/BambuStudio/blob/master/deps/OpenMeshCraft/OpenMeshCraft.cmake
      - type: file
        url: https://github.com/bambulab/OpenMeshCraft/archive/0e8d12c3df54804393593ab5d86c05caa340cbee.zip
        dest: external-packages/OpenMeshCraft
        sha256: 632CD806CE932D6A1D76DF0E86ECF8BFC22480E76F80A638A28474F5262E2B9E

generates the following error:

Failed to download sources: module BambuStudio: Wrong sha256 checksum for 0e8d12c3df54804393593ab5d86c05caa340cbee.zip, expected "632CD806CE932D6A1D76DF0E86ECF8BFC22480E76F80A638A28474F5262E2B9E", was "632cd806ce932d6a1d76df0e86ecf8bfc22480e76f80a638a28474f5262e2b9e"

I think that flatpak-builder should probably compare checksums case insensitively. Maybe something like this?

diff --git a/src/builder-utils.c b/src/builder-utils.c
index c0f383a7a798..1d647d137c3b 100644
--- a/src/builder-utils.c
+++ b/src/builder-utils.c
@@ -1220,13 +1220,15 @@ compare_checksum (const char *name,
 {
   const char *type_names[] = { "md5", "sha1", "sha256", "sha512", "sha384" }; /* In GChecksumType order */
   const char *type_name;
+  guint len;
 
   if (checksum_type < G_N_ELEMENTS (type_names))
     type_name = type_names[checksum_type];
   else
     type_name = "unknown";
 
-  if (strcmp (expected_checksum, measured_checksum) != 0)
+  len = MIN(strlen(expected_checksum), strlen(measured_checksum));
+  if (g_ascii_strncasecmp (expected_checksum, measured_checksum, len) != 0)
     {   
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                    "Wrong %s checksum for %s, expected \"%s\", was \"%s\"", type_name, name,

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