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-next>] [day] [month] [year] [list]
Date:	Mon, 29 Nov 2010 05:09:10 +0300
From:	Pavel Vasilyev <pavel@...linux.ru>
To:	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] Repalce strncmp by memcmp


    This patch replace all strncmp(a, b, c) by  memcmp(a, b, c).

I test on x86_64 (AMD Opteron 285).

#include <string.h>
char *A = "0000";
void test_memcmp(void) {
        memcmp(A, "TEST", 4);
}
void test_strn(void) {
        strncmp(A, "TEST", 4);
}
# gcc -c -O2 test.c
# objdump -d test.o
...

0000000000000020 <test_strncmp>:
  20:   f3 c3                   repz retq
  22:   66 66 66 66 66 2e 0f    data32 data32 data32 data32 nopw
%cs:0x0(%rax,%rax,1)
  29:   1f 84 00 00 00 00 00

0000000000000030 <test_memcmp>:
  30:   f3 c3                   repz retq

Wow, minus  one commad :)

-- 

                                                         Pavel.


View attachment "strncmp2memcmp-2.6.37-rc3-git5.patch" of type "text/x-patch" (549436 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ