File: format_string_fix.diff

package info (click to toggle)
libfile-mmagic-xs-perl 0.09008-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: perl: 2,130; ansic: 1,858; makefile: 12; xml: 1
file content (30 lines) | stat: -rw-r--r-- 906 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
>From 2a247110eb4ec1828e844410dd83249bb5af1e1e Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Mon, 5 Mar 2012 22:13:56 +0200
Subject: [PATCH] Call croak() with a controlled format string

Bug-Debian: https://bugs.debian.org/661539
Bug: https://rt.cpan.org/Public/Bug/Display.html?id=75568

This fixes builds with -Werror=format-security.

The fatal error with an invalid offset contains a format string error
that could be triggered with a crafted magic line.

$ perl -MFile::MMagic::XS -e 'File::MMagic::XS->new->add_magic("%s%s%s%s")'
Segmentation fault (core dumped)
---
 src/perl-mmagic-xs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

--- a/src/perl-mmagic-xs.c
+++ b/src/perl-mmagic-xs.c
@@ -1110,7 +1110,7 @@
 
  error:
     FMM_SET_ERROR(state, err);
-    croak(SvPV_nolen(err));
+    croak("%s", SvPV_nolen(err));
 }
 
 /* maps to mod_mime_magic::apprentice */