Newer
Older
From 258b47372d3e275a2d3cfa7d80d476fbcb92b5a9 Mon Sep 17 00:00:00 2001
From: Clemens Terasa <clemens.terasa@garz-fricke.com>
Date: Fri, 25 Sep 2020 08:11:08 +0200
Subject: [PATCH] ximtoppm: Fix string copy
Fix a string duplication issue previously done wrong.
The implementation createt warnings for security reasons with
-Wformat-security. This is due to a anti-pattern heaving a variable
string as format specifier of a printf-family function.
Instead use a strdup variant.
See commit https://sourceforge.net/p/netpbm/code/3939/
---
converter/ppm/ximtoppm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c
index dc04b36..4fbfe75 100644
--- a/converter/ppm/ximtoppm.c
+++ b/converter/ppm/ximtoppm.c
@@ -116,9 +116,10 @@ ReadXimHeader(FILE * const in_fp,
*/
header->bits_channel = atoi(a_head.bits_per_channel);
header->alpha_flag = atoi(a_head.alpha_channel);
- pm_asprintf(&header->author, a_head.author);
- pm_asprintf(&header->date, a_head.date);
- pm_asprintf(&header->program, a_head.program);
+ header->author = pm_strdup(a_head.author);
+ header->date = pm_strdup(a_head.date);
+ header->program = pm_strdup(a_head.program);
+
/* Do double checking for bakwards compatibility */
if (header->npics == 0)
header->npics = 1;