Skip to content
Snippets Groups Projects
Commit c7c8ab7c authored by Reid Rankin's avatar Reid Rankin Committed by Timo Teräs
Browse files

don't use hardcoded checksum buffer sizes

parent aa882df5
No related branches found
No related tags found
No related merge requests found
......@@ -36,12 +36,15 @@ extern apk_blob_t apk_null_blob;
#define APK_CHECKSUM_MD5 16
#define APK_CHECKSUM_SHA1 20
#define APK_CHECKSUM_DEFAULT APK_CHECKSUM_SHA1
#define APK_CHECKSUM_MAX APK_CHECKSUM_SHA1
#define APK_BLOB_CHECKSUM_BUF 34
/* Enough space for a hexdump of the longest checksum possible plus
* a two-character type prefix */
#define APK_BLOB_CHECKSUM_BUF (2 + (2 * APK_CHECKSUM_MAX))
/* Internal cointainer for MD5 or SHA1 */
/* Internal container for checksums */
struct apk_checksum {
unsigned char data[20];
unsigned char data[APK_CHECKSUM_MAX];
unsigned char type;
};
......
......@@ -36,7 +36,7 @@ static void process_package(struct apk_database *db, struct apk_package *pkg)
struct apk_db_dir_instance *diri;
struct apk_db_file *file;
struct hlist_node *dc, *dn, *fc, *fn;
char csum_buf[(APK_CHECKSUM_SHA1 * 2) + 1];
char csum_buf[APK_BLOB_CHECKSUM_BUF];
if (ipkg == NULL)
return;
......@@ -62,7 +62,7 @@ static int read_file_entry(void *ctx, const struct apk_file_info *ae,
struct apk_istream *is)
{
struct manifest_file_ctx *mctx = ctx;
char csum_buf[(APK_CHECKSUM_SHA1 * 2) + 1];
char csum_buf[APK_BLOB_CHECKSUM_BUF];
apk_blob_t csum_blob = APK_BLOB_BUF(csum_buf);
int r;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment