lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Mon, 17 Apr 2006 17:06:28 -0700
From: "Michael Wojcik" <Michael.Wojcik@...rofocus.com>
To: <bugtraq@...urityfocus.com>
Subject: RE: gcc 4.1 bug miscompiles pointer range checks, may place you at risk


> From: Felix von Leitner [mailto:felix-bugtraq@...e.de] 
> Sent: Monday, 17 April, 2006 16:04
> 
> static inline int range_ptrinbuf(const void* buf,unsigned 
> long len,const void* ptr) {
>   register const char* c=(const char*)buf;      /* no pointer 
> arithmetic on void* */
>   return (c && c+len>c && (const char*)ptr-c<len);
> }
> 
> ...
>   assert(range_ptrinbuf(buf,(unsigned long)-1,buf+1)==0);
> 
> Imagine my surprise when this assertion failed.

As far as the C language is concerned, this isn't a compiler "bug".
You've created an invalid pointer in "c+len" (the result neither points
within the object that includes the location c points to, nor one past
it), which invokes Undefined Behavior (ISO 9899:1990 6.5.6 #8).  And
you've compared two pointers which do not point within the same object
("c+len>c"), which also invokes Undefined Behavior (6.5.8 #5).

The behavior of gcc 4.1 in this case might be infelicitous, but it is
not, properly speaking, a bug.

-- 
Michael Wojcik
Principal Software Systems Developer, Micro Focus


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ