goto ERROR;
}
+ const char* entry_name = archive_entry_pathname(entry);
+
+ // Check for filename (must be "pakfire-format")
+ if (strcmp(entry_name, "pakfire-format") != 0) {
+ DEBUG(archive->pakfire, "First file is not named \"pakfire-format\"");
+ r = 1;
+ goto ERROR;
+ }
+
+ // The file cannot be larger than a couple of bytes
+ size = archive_entry_size(entry);
+ if (size == 0 || size >= 128) {
+ DEBUG(archive->pakfire, "pakfire-format is of an invalid size: %zu bytes\n", size);
+ r = 1;
+ goto ERROR;
+ }
+
// Read the entire payload
r = pakfire_archive_copy_data_to_buffer(archive->pakfire, a, entry, &data, &size);
if (r) {
if (data)
free(data);
- return 0;
+ return r;
}
static int pakfire_archive_try_open(PakfireArchive archive, const char* path) {