log_err, cil_printf and cil_println use printf formats to process their arguments. Use __attribute__((format(printf,...))) to make "gcc -Wformat -Wformat-security" detect issues. This detected this issue several times on a x86_64 system: format '%lx' expects argument of type 'long unsigned int', but argument has type 'uint32_t' Fix this by introducing an explicit cast to unsigned long. While at it, constify the format string argument of each function. --- policycoreutils/hll/pp/pp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/policycoreutils/hll/pp/pp.c b/policycoreutils/hll/pp/pp.c index fd80657321bc..93e2889b78f6 100644 --- a/policycoreutils/hll/pp/pp.c +++ b/policycoreutils/hll/pp/pp.c @@ -54,7 +54,8 @@ FILE *out_file; #define DEFAULT_LEVEL "systemlow" #define DEFAULT_OBJECT "object_r" -static void log_err(char *fmt, ...) +__attribute__ ((format(printf, 1, 2))) +static void log_err(const char *fmt, ...) { va_list argptr; va_start(argptr, fmt); @@ -75,7 +76,8 @@ static void cil_indent(int indent) } } -static void cil_printf(char *fmt, ...) { +__attribute__ ((format(printf, 1, 2))) +static void cil_printf(const char *fmt, ...) { va_list argptr; va_start(argptr, fmt); if (vfprintf(out_file, fmt, argptr) < 0) { @@ -85,7 +87,8 @@ static void cil_printf(char *fmt, ...) { va_end(argptr); } -static void cil_println(int indent, char *fmt, ...) +__attribute__ ((format(printf, 2, 3))) +static void cil_println(int indent, const char *fmt, ...) { cil_indent(indent); va_list argptr; @@ -2200,9 +2203,9 @@ static int ocontext_xen_iomem_to_cil(struct policydb *pdb, struct ocontext *iome high = iomem->u.iomem.high_iomem; if (low == high) { - cil_printf("(iomemcon %#lX ", low); + cil_printf("(iomemcon %#lX ", (unsigned long)low); } else { - cil_printf("(iomemcon (%#lX %#lX) ", low, high); + cil_printf("(iomemcon (%#lX %#lX) ", (unsigned long)low, (unsigned long)high); } context_to_cil(pdb, &iomem->context[0]); @@ -2218,7 +2221,7 @@ static int ocontext_xen_pcidevice_to_cil(struct policydb *pdb, struct ocontext * struct ocontext *pcid; for (pcid = pcids; pcid != NULL; pcid = pcid->next) { - cil_printf("(pcidevicecon %#lx ", pcid->u.device); + cil_printf("(pcidevicecon %#lx ", (unsigned long)pcid->u.device); context_to_cil(pdb, &pcid->context[0]); cil_printf(")\n"); } -- 2.1.0 _______________________________________________ Selinux mailing list Selinux@xxxxxxxxxxxxx To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx. To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.