Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240718181704.GQ10433@brightrain.aerifal.cx>
Date: Thu, 18 Jul 2024 14:17:04 -0400
From: Rich Felker <dalias@...c.org>
To: Thorsten Glaser <tg@...bsd.de>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH 1/1] FD_SET() and FD_ISSET() warn on
 -Wsign-conversion

On Thu, Jul 18, 2024 at 05:35:25PM +0000, Thorsten Glaser wrote:
> Rich Felker dixit:
> 
> >Use of signed ints generates worse code (not just bitshift/mask, needs
> >fixup for C's wrong definition of signed integer division) and has
> >more-dangerous behavior in the event of a negative input (small
> >negative offset likely to clobber data in an exploitable way rather
> >than giant positive offset likely to crash).
> 
> Aieee. I see, more reasons against signed integers in C :/
> 
> #define FD_SET(d,s)	((s)->fds_bits[(0U + (d)) / (8 * sizeof(long))] |= \
> 			    (1UL << ((0U + (d)) % (8 * sizeof(long)))))
> 
> Maybe this?

I would expect that to produce the exact same warning as promition via
division by an unsigned expression.

Rich

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.