update-copyright copyright notice corruption bug
Andreas Jaeger
aj@suse.com
Thu Jan 3 09:39:00 GMT 2013
On 01/03/2013 10:25 AM, Jim Meyering wrote:
> Joseph S. Myers wrote:
>> On Wed, 2 Jan 2013, Eric Blake wrote:
>>
>>> The original was:
>>>
>>> Copyright (C) 1995,97,99 Free Software Foundation, Inc.
>>>
>>> and that pattern (4-digits followed by 2-digits, with gaps in the years,
>>> but no spaces in the listing) is not currently tested in the
>>> update-copyright testsuite.
>>
>> I don't believe the "no spaces" is required for this bug to show. The
>> corruption also appeared for misc/sys/file.h, for example:
>>
>> -/* Copyright (C) 1991, 92, 96, 97, 98, 99 Free Software Foundation, Inc.
>> +/* Copyright (C) 11999, 20131, 1992-1999 Free Software Foundation, Inc.
>
> Here's a minimal test case:
>
> $ echo '/* Copyright 1991, 99 Free Software Foundation, Inc. */' > k.c
> $ build-aux/update-copyright k.c && cat k.c
> /* Copyright 11999, 20131, 1999 Free Software Foundation, Inc. */
>
> It tickles a bug whereby an attempt to replace that "final" year number, 99,
> with 1999 mistakenly matches the "99" in the middle of the *first* date, 1991:
>
> Here's the fix:
>
> From 25b6e62a48c9991f8166c490463cf73ebc874db4 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <jim@meyering.net>
> Date: Thu, 3 Jan 2013 10:23:30 +0100
> Subject: [PATCH] update-copyright: avoid copyright notice date corruption
>
> Given a sequence of copyright year numbers in which the final
> one was a two-digit number that happened to be a substring of
> a preceding four-digit year number, we would mistakenly update
> the substring (from two- to four-digit) rather than the two-digit
> number at the end, which, combined with the addition of the current
> 4-digit year number would yield two 5-digit year numbers, e.g.,
> here, it would convert the first "99" to "1999, 2013" rather than
> the final one:
> 1991, 99
> 11999, 20131, 1999
> * build-aux/update-copyright: Tighten a regexp.
> * tests/test-update-copyright.sh: Add a test case to trigger the bug.
> Reported by Joseph Myers in
> http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/32281
> ---
> ChangeLog | 18 ++++++++++++++++++
> build-aux/update-copyright | 2 +-
> tests/test-update-copyright.sh | 6 ++++++
> 3 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index db79efc..73c186d 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,21 @@
> +2013-01-03 Jim Meyering <jim@meyering.net>
> +
> + update-copyright: avoid copyright notice date corruption
> + Given a sequence of copyright year numbers in which the final
> + one was a two-digit number that happened to be a substring of
> + a preceding four-digit year number, we would mistakenly update
> + the substring (from two- to four-digit) rather than the two-digit
> + number at the end, which, combined with the addition of the current
> + 4-digit year number would yield two 5-digit year numbers, e.g.,
> + here, it would convert the first "99" to "1999, 2013" rather than
> + the final one:
> + 1991, 99
> + 11999, 20131, 1999
> + * build-aux/update-copyright: Tighten a regexp.
Jim, it seems your diff below does not include the change above.
Andreas
> + * tests/test-update-copyright.sh: Add a test case to trigger the bug.
> + Reported by Joseph Myers in
> + http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/32281
> +
> 2013-01-01 Paul Eggert <eggert@cs.ucla.edu>
>
> regex: omit needless signed-pointer casts
> diff --git a/build-aux/update-copyright b/build-aux/update-copyright
> index c51ac64..da84c66 100755
> --- a/build-aux/update-copyright
> +++ b/build-aux/update-copyright
> @@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" ${1+"$@"}'
> if 0;
> # Update an FSF copyright year list to include the current year.
>
> -my $VERSION = '2012-02-05.21:39'; # UTC
> +my $VERSION = '2013-01-03.08:43'; # UTC
>
> # Copyright (C) 2009-2013 Free Software Foundation, Inc.
> #
> diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh
> index efecebe..60cb372 100755
> --- a/tests/test-update-copyright.sh
> +++ b/tests/test-update-copyright.sh
> @@ -505,6 +505,9 @@ cat > $TMP.extra-text-space <<EOF
> /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. ***
> * End of comments. */
> EOF
> +cat > $TMP.two-digit-final-is-substr-of-first <<EOF
> + /* Copyright 1991, 99 Free Software Foundation, Inc. */
> +EOF
> UPDATE_COPYRIGHT_YEAR=2010 \
> update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
> compare /dev/null $TMP-stdout || exit 1
> @@ -536,6 +539,9 @@ compare - $TMP.extra-text-space <<EOF || exit 1
> Inc. ***
> * End of comments. */
> EOF
> +compare - $TMP.two-digit-final-is-substr-of-first <<EOF || exit 1
> + /* Copyright 1991, 1999, 2010 Free Software Foundation, Inc. */
> +EOF
> rm $TMP*
>
> exit 0
> --
> 1.8.1
>
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list