public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Rafal Luzynski <digitalfreak@lingonborough.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: libc-alpha@sourceware.org, Florian Weimer <fweimer@redhat.com>
Subject: Re: [RFC][PATCH v4 06/11] Provide backward compatibility for strftime family (bug 10871).
Date: Tue, 15 Nov 2016 01:21:00 -0000	[thread overview]
Message-ID: <889064307.140264.1479172873339@poczta.nazwa.pl> (raw)
In-Reply-To: <87k2cbuoq9.fsf@linux-m68k.org>

10.11.2016 20:19 Andreas Schwab <schwab@linux-m68k.org> wrote:
>
>
> On Nov 10 2016, Rafal Luzynski <digitalfreak@lingonborough.com> wrote:
>
> > I was investigating these cases long ago and in Linux only,
> > sorry if I'm inaccurate and please tell me if an actual investigation
> > is needed again. I don't know if FreeBSD uses the same GNU coreutils
> > as Linux does but if it does then it's not a surprise if some bugs
> > are common.
>
> FreeBSD generally does not use GNU tools. Here is the source for date,
> for example:
>
> https://svnweb.freebsd.org/base/head/bin/date/
>
> Andreas.

Thank you for this link, Andreas.  I took the opportunity to analyze the
problem more thoroughly.

1. date utility in FreeBSD actually calls strftime() directly which makes
   it vulnerable to memory overflow if the format string is maliciously
   long, an issue which has been fixed in glibc a while ago.  That means
   that whole implementation of date format is inside strftime().
   The default format for a date is "%+" (not supported in glibc2)
   which uses whatever is provided in locale data as date_fmt field.
2. In case of Catalan language, date_fmt and other formats had many
   changes this year but the additional unnecessary "de" before the
   month name has been added only in the last commit, on Aug 13, 2016.
   It did not exist before.  Florian, your FreeBSD says it's release 11.0
   from Sep 29, 2016.  All this looks like you have spotted a bug,
   not present in the older releases and not yet fixed.  I don't know
   why this change has been introduced, the commit comment says
   that the time data from CLDR are not good but does not explain where
   the format containing the additional "de" comes from.
   Catalan language has been added to FreeBSD only in October 2015.
   While at this, it seems strange to me that it is listed as ca_IT
   rather than ca_ES but I guess it does work anyway.
3. In case of cal utility I'm not sure if it's a core part of FreeBSD
   because FreeBSD manuals say that ncal is its native cal implementation.
   I'm not sure where cal comes from.  If it comes from Linux or from
   another non-BSD source then it may have the same problems I mentioned
   before: it displays nl_langinfo(MON_1+x) which may return a month
   name in a genitive form (or whatever is appropriate when printing
   a month name in a full date context but not standalone), one of
   those issues which will be introduced by my proposed change.
   At the same time, ncal uses wcsprintf("%OB") - correctly!
4. Unfortunately, there seem to be no more Western European languages
   supported in FreeBSD and featuring any difference between %B and %OB
   months names.

Please note that whether we implement nominative (standalone) cases
as %OB/ALTMON_x and genitive (full date) as %B/MON_x or the other
way round it does not change the vulnerability to the incorrect
format strings.  If the format string for Catalan (or any other
similar language) contains additional "de" while the month name
is already in its genitive form then whole format string becomes
incorrect no matter which implementation we choose.

Regards,

Rafal

  reply	other threads:[~2016-11-15  1:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28  0:49 Rafal Luzynski
2016-11-04 13:40 ` Florian Weimer
2016-11-05 10:53   ` Rafal Luzynski
2016-11-07 14:13     ` Florian Weimer
2016-11-08 11:39       ` Rafal Luzynski
2016-11-09 10:49         ` Florian Weimer
2016-11-10  0:33           ` Rafal Luzynski
2016-11-10 12:41             ` Florian Weimer
2016-11-10 18:42               ` Rafal Luzynski
2016-11-10 19:19                 ` Andreas Schwab
2016-11-15  1:21                   ` Rafal Luzynski [this message]
2016-11-11  3:52             ` Rical Jasan
2016-11-15  1:38               ` Rafal Luzynski
2016-11-15 11:09                 ` Rafal Luzynski
2016-11-16 13:06                 ` Rical Jasan
2016-11-17 11:18                   ` Rafal Luzynski
2016-11-18  9:22                     ` Rical Jasan
2016-11-22 23:56                       ` Rafal Luzynski
2016-11-09 11:00       ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=889064307.140264.1479172873339@poczta.nazwa.pl \
    --to=digitalfreak@lingonborough.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).