- djm@cvs.openbsd.org 2010/07/21 02:10:58

[misc.c]
     sync timingsafe_bcmp() with the one dempsky@ committed to sys/lib/libkern
This commit is contained in:
Damien Miller 2010-08-03 16:05:05 +10:00
parent e11e1ea5d4
commit 8c1eb113ef
2 changed files with 9 additions and 8 deletions

View File

@ -24,6 +24,9 @@
duration of inactivity. bz#1330 - patch by dwmw2 AT infradead.org, but duration of inactivity. bz#1330 - patch by dwmw2 AT infradead.org, but
further hacked on by wmertens AT cisco.com, apb AT cequrux.com, further hacked on by wmertens AT cisco.com, apb AT cequrux.com,
martin-mindrot-bugzilla AT earth.li and myself; "looks ok" markus@ martin-mindrot-bugzilla AT earth.li and myself; "looks ok" markus@
- djm@cvs.openbsd.org 2010/07/21 02:10:58
[misc.c]
sync timingsafe_bcmp() with the one dempsky@ committed to sys/lib/libkern
20100819 20100819
- (dtucker) [contrib/ssh-copy-ud.1] Bug #1786: update ssh-copy-id.1 with more - (dtucker) [contrib/ssh-copy-ud.1] Bug #1786: update ssh-copy-id.1 with more

14
misc.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.79 2010/07/13 23:13:16 djm Exp $ */ /* $OpenBSD: misc.c,v 1.80 2010/07/21 02:10:58 djm Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005,2006 Damien Miller. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@ -851,17 +851,15 @@ ms_to_timeval(struct timeval *tv, int ms)
} }
int int
timingsafe_bcmp(const void *_s1, const void *_s2, size_t n) timingsafe_bcmp(const void *b1, const void *b2, size_t n)
{ {
u_char *s1 = (u_char *)_s1; const unsigned char *p1 = b1, *p2 = b2;
u_char *s2 = (u_char *)_s2;
int ret = 0; int ret = 0;
for (; n > 0; n--, s1++, s2++) for (; n > 0; n--)
ret |= *s1 ^ *s2; ret |= *p1++ ^ *p2++;
return ret; return (ret != 0);
} }
void void
sock_set_v6only(int s) sock_set_v6only(int s)
{ {