From 6622f25f95148e5e78a56900242f478de0e40427 Mon Sep 17 00:00:00 2001 From: Konrad Dybcio Date: Wed, 15 May 2024 00:41:01 +0200 Subject: [PATCH 1/2] firehose: Fix xml_setpropf format for payload_size CodeQL reports: This argument should be of type 'int' but is of type 'unsigned long'. Signed-off-by: Konrad Dybcio --- firehose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firehose.c b/firehose.c index 9e47f64..974180c 100644 --- a/firehose.c +++ b/firehose.c @@ -248,7 +248,7 @@ static int firehose_send_configure(struct qdl_device *qdl, size_t payload_size, node = xmlNewChild(root, NULL, (xmlChar*)"configure", NULL); xml_setpropf(node, "MemoryName", storage); - xml_setpropf(node, "MaxPayloadSizeToTargetInBytes", "%d", payload_size); + xml_setpropf(node, "MaxPayloadSizeToTargetInBytes", "%lu", payload_size); xml_setpropf(node, "verbose", "%d", 0); xml_setpropf(node, "ZLPAwareHost", "%d", 1); xml_setpropf(node, "SkipStorageInit", "%d", skip_storage_init); From 766123c751a52fcc51aee837775e1e6901113d99 Mon Sep 17 00:00:00 2001 From: Konrad Dybcio Date: Wed, 15 May 2024 00:43:31 +0200 Subject: [PATCH 2/2] firehose: Prevent potential overflow in info print also fixes the improper format specifier i suppose CodeQL reports: Multiplication result may overflow 'unsigned int' before it is converted to 'long'. Signed-off-by: Konrad Dybcio --- firehose.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firehose.c b/firehose.c index 974180c..da3ed31 100644 --- a/firehose.c +++ b/firehose.c @@ -417,9 +417,9 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int fprintf(stderr, "[PROGRAM] failed\n"); } else if (t) { fprintf(stderr, - "[PROGRAM] flashed \"%s\" successfully at %ldkB/s\n", + "[PROGRAM] flashed \"%s\" successfully at %lukB/s\n", program->label, - program->sector_size * num_sectors / t / 1024); + (unsigned long)program->sector_size * num_sectors / t / 1024); } else { fprintf(stderr, "[PROGRAM] flashed \"%s\" successfully\n", program->label);