* [PATCH] Fix crash of ffs (0x80000000) on 64 bit
@ 2014-09-23 16:01 Christian Franke
2014-10-08 16:35 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Christian Franke @ 2014-09-23 16:01 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 184 bytes --]
This fixes the issue reported here:
https://cygwin.com/ml/cygwin/2014-09/msg00341.html
On 64 bit, i = 0x80000000 results in x = 0xffffffff80000000 due to sign
extension.
Christian
[-- Attachment #2: ffs-crash-on-x86_64.patch --]
[-- Type: text/x-patch, Size: 726 bytes --]
2014-09-23 Christian Franke <franke@computer.org>
* syscall.cc (ffs): Fix crash of ffs (0x80000000) on 64 bit.
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 15ebf49..044e003 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3847,10 +3847,9 @@ ffs (int i)
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
};
- unsigned long int a;
- unsigned long int x = i & -i;
+ unsigned x = i & -i;
- a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24);
+ int a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24);
return table[x >> a] + a;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix crash of ffs (0x80000000) on 64 bit
2014-09-23 16:01 [PATCH] Fix crash of ffs (0x80000000) on 64 bit Christian Franke
@ 2014-10-08 16:35 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2014-10-08 16:35 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
On Sep 23 18:01, Christian Franke wrote:
> This fixes the issue reported here:
> https://cygwin.com/ml/cygwin/2014-09/msg00341.html
>
> On 64 bit, i = 0x80000000 results in x = 0xffffffff80000000 due to sign
> extension.
>
> Christian
>
> 2014-09-23 Christian Franke <...>
>
> * syscall.cc (ffs): Fix crash of ffs (0x80000000) on 64 bit.
Applied.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-08 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-23 16:01 [PATCH] Fix crash of ffs (0x80000000) on 64 bit Christian Franke
2014-10-08 16:35 ` Corinna Vinschen
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).