Fix copying overlapping comments when using -fca option

epel9
Petr Písař 12 years ago
parent ad818a22d6
commit 6c43ed21d9

@ -0,0 +1,51 @@
From 9e8a1699099f9aea5da11064e3aa9387ae9cffc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 7 Mar 2013 11:32:02 +0100
Subject: [PATCH] Fix copying overlapping comment
Reformating block comments with -fca option triggered memcpy() on
overlapping areas.
E.g. comment:
/* Some statement. Unless it's special, arrange
* to break the line. */
from indent-2.2.11/indent.c hits it:
$ valgrind -- ./indent -o /dev/null -fca indent.c
Memcheck, a memory error detector
Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
Command: ./indent -o /dev/null -fca indent.c
Source and destination overlap in memcpy(0x4c2c3c4, 0x4c2c3c9, 6)
at 0x4A0A230: memcpy@@GLIBC_2.14 (mc_replace_strmem.c:882)
by 0x404EA7: print_comment (comments.c:857)
by 0x40EB92: handle_token_comment (handletoken.c:2119)
by 0x40EF38: handle_the_token (handletoken.c:2315)
by 0x401FDB: indent_main_loop (indent.c:628)
by 0x4021CD: indent (indent.c:715)
by 0x402869: indent_single_file (indent.c:960)
by 0x4028F1: indent_all (indent.c:992)
by 0x4029E5: main (indent.c:1054)
---
src/comments.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/comments.c b/src/comments.c
index 01776e8..2ee8fc6 100644
--- a/src/comments.c
+++ b/src/comments.c
@@ -854,7 +854,7 @@ begin_line:
save_length--;
}
- (void) memcpy (e_com, save_ptr, save_length);
+ (void) memmove (e_com, save_ptr, save_length);
text_on_line = e_com;
e_com += save_length;
--
1.8.1.4

@ -2,7 +2,7 @@
Summary: A GNU program for formatting C code Summary: A GNU program for formatting C code
Name: indent Name: indent
Version: 2.2.11 Version: 2.2.11
Release: 9%{?dist} Release: 10%{?dist}
License: GPLv3+ License: GPLv3+
Group: Applications/Text Group: Applications/Text
URL: http://indent.isidore-it.eu/beautify.html URL: http://indent.isidore-it.eu/beautify.html
@ -19,6 +19,8 @@ Patch9: indent-2.2.11-Return-non-zero-exit-code-on-tests-failure.patch
Patch10: indent-2.2.11-Fix-compiler-warnings.patch Patch10: indent-2.2.11-Fix-compiler-warnings.patch
# Submitted to upstream, bug #912635 # Submitted to upstream, bug #912635
Patch11: indent-2.2.11-Allow-64-bit-stat.patch Patch11: indent-2.2.11-Allow-64-bit-stat.patch
# Submitted to upstream
Patch12: indent-2.2.11-Fix-copying-overlapping-comment.patch
# gperf to update pre-generated code to fix compiler warnings # gperf to update pre-generated code to fix compiler warnings
BuildRequires: gperf BuildRequires: gperf
BuildRequires: texinfo texi2html BuildRequires: texinfo texi2html
@ -42,6 +44,7 @@ you want a program to format your code.
%patch9 -p1 -b .exit_code %patch9 -p1 -b .exit_code
%patch10 -p1 -b .warnings %patch10 -p1 -b .warnings
%patch11 -p1 -b .warnings %patch11 -p1 -b .warnings
%patch12 -p1 -b .comments
# Regenerate sources # Regenerate sources
rm src/gperf.c src/gperf-cc.c rm src/gperf.c src/gperf-cc.c
@ -76,6 +79,9 @@ fi
%changelog %changelog
* Thu Mar 07 2013 Petr Pisar <ppisar@redhat.com> - 2.2.11-10
- Fix copying overlapping comments when using -fca option
* Tue Feb 19 2013 Petr Pisar <ppisar@redhat.com> - 2.2.11-9 * Tue Feb 19 2013 Petr Pisar <ppisar@redhat.com> - 2.2.11-9
- Fix compiler warnings - Fix compiler warnings
- Enable 64-bit stat (bug #912635) - Enable 64-bit stat (bug #912635)

Loading…
Cancel
Save