Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Wed, 27 Apr 2016 18:01:05 -0400
From: Rich Felker <>
Subject: [PATCH] un-UBify string functions

The attached patch is a first draft of an attempt to get rid of UB in
src/string/* by using the may_alias attribute correctly conditional on
__GNUC__. I've tried to structure it so that it's obvious there are no
semantic changes in the __GNUC__ case (memchr.c had some slight
structural changes, but the condition removed was already implied by
the for loop conditions), which unfortunately leaves everything pretty
ugly and with inconsistent style. We should probably pick some
canonical, well-styled files, write the fully-general (byte-match &&
size-limit end conditions) versions of both search and copy, and then
either write all the simpler versions in matching style, or write a
pair of common templates that optimize-down to individual functions
like strlen, stpcpy, etc.

At least memmove needs to be done separately (it doesn't fit the
pattern of the others), and there might be other omissions too. But
this is at least a good starting point for review.


View attachment "un-UB-strings.diff" of type "text/plain" (5515 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.