mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Fix strverscmp
Date: Wed, 5 Dec 2012 14:35:21 -0500	[thread overview]
Message-ID: <20121205193520.GN20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <20121205110959.87b6111a.idunham@lavabit.com>

On Wed, Dec 05, 2012 at 11:09:59AM -0800, Isaac Dunham wrote:
> On the Puppy Linux forums, technosaurus mentioned that musl's
> strverscmp implementation was broken; he has a small version of
> strverscmp that works properly, which he placed under a CC0-like
> license.
> 
> This patch changes strverscmp to use his version. Results are
> comparable to glibc.

I'm not opposed to adding this, but the code has some bugs, most
notably integer overflow. On filenames consisting of long digit
strings, it will invoke undefined behavior. If the results are
unpredictable, it might even cause qsort to invoke very bad undefined
behavior.

It would also, for example, cause these two names to compare equal:

- foobar-1.1.2
- foobar-1.01.3

just because the first component that differs textually compares equal
numerically.

It also shares the same issues (which we should arguably duplicate
anyway) with the original strverscmp, that names consisting of hex
values get sorted in a ridiculous and harmful way.

If we're to implement this function, some thought about getting it
correct is needed..

Rich


  reply	other threads:[~2012-12-05 19:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05 19:09 Isaac Dunham
2012-12-05 19:35 ` Rich Felker [this message]
2012-12-06  0:43   ` Isaac Dunham
2012-12-06  1:00     ` Rich Felker
2012-12-06  2:14       ` Rich Felker
2012-12-06  2:21       ` Isaac Dunham
2012-12-06  2:26         ` Rich Felker
2012-12-06  3:18           ` Isaac Dunham
2012-12-06  4:14             ` Rich Felker
2012-12-07  0:36               ` Isaac Dunham

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=20121205193520.GN20323@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).