Mercurial > dropbear
comparison dbutil.c @ 1283:3017bc7d6238
move m_burn and function attributes to dbhelpers
use m_burn for libtomcrypt zeromem() too
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 17 Mar 2016 23:21:33 +0800 |
parents | 94d4038bb34c |
children | 750ec4ec4cbe efad433418c4 |
comparison
equal
deleted
inserted
replaced
1282:a3bb15115816 | 1283:3017bc7d6238 |
---|---|
557 dropbear_exit("m_realloc failed"); | 557 dropbear_exit("m_realloc failed"); |
558 } | 558 } |
559 return ret; | 559 return ret; |
560 } | 560 } |
561 | 561 |
562 /* Clear the data, based on the method in David Wheeler's | |
563 * "Secure Programming for Linux and Unix HOWTO" */ | |
564 /* Beware of calling this from within dbutil.c - things might get | |
565 * optimised away */ | |
566 void m_burn(void *data, unsigned int len) { | |
567 | |
568 #if defined(HAVE_MEMSET_S) | |
569 memset_s(data, len, 0x0, len); | |
570 #elif defined(HAVE_EXPLICIT_BZERO) | |
571 explicit_bzero(data, len); | |
572 #else | |
573 volatile char *p = data; | |
574 | |
575 if (data == NULL) | |
576 return; | |
577 while (len--) { | |
578 *p++ = 0x0; | |
579 } | |
580 #endif | |
581 } | |
582 | |
583 | |
584 void setnonblocking(int fd) { | 562 void setnonblocking(int fd) { |
585 | 563 |
586 TRACE(("setnonblocking: %d", fd)) | 564 TRACE(("setnonblocking: %d", fd)) |
587 | 565 |
588 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { | 566 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { |