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>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <200305301541.h4UFfce6006210@turing-police.cc.vt.edu>
From: Valdis.Kletnieks at vt.edu (Valdis.Kletnieks@...edu)
Subject: C99 Security Alert-Old-New-Who-Cares :) - (: 

On Fri, 30 May 2003 04:05:32 -0000, "democow ...." <democow8086@...mail.com>  said:

> char * strcpy(char * dest,const char *src)
> {
>         char *tmp = dest;
> 
>       [1]  while ((*dest++ = *src++) != '\0')
>                 /* nothing */;
>         return tmp;
> }

Kernighan & Ritchie, "The C Programming Language", had this in the first
edition - and correctly noted that this can be further optimized to:

             while (*dest++ = *src++);

eliminating a comparison to '\0'.  So not only is it insecure, but it's
inefficient, unless you have a *really* good optimizing compiler that can
tell that the comparison to null can be optimized away.  And yes, you
need a *good* optimizer that can see that comparing to a null byte is
a special case (for instance, you can't optimize   != '\n'  the same way).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 226 bytes
Desc: not available
Url : http://lists.grok.org.uk/pipermail/full-disclosure/attachments/20030530/257bca02/attachment.bin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ