Permalink
Browse files

Zero all the things!

  • Loading branch information...
msantos committed Feb 3, 2013
1 parent 819a75d commit 29bb20df59f0081310b1461a94ff8f0b7146d8b7
Showing with 12 additions and 19 deletions.
  1. +6 −12 sdt/sdt_dns.c
  2. +2 −2 sods/sods.c
  3. +2 −3 sods/sods_dns.c
  4. +2 −2 sods/sods_io.c
View
@@ -100,9 +100,9 @@ sdt_dns_setns(char *ns)
sdt_dns_A(SDT_STATE *ss, char *buf, ssize_t n)
{
char *p = NULL;
- char dn[NS_MAXDNAME];
- char query[NS_MAXDNAME];
- char pkt[NS_PACKETSZ];
+ char dn[NS_MAXDNAME] = {0};
+ char query[NS_MAXDNAME] = {0};
+ char pkt[NS_PACKETSZ] = {0};
int i = 0;
int j = 0;
@@ -112,10 +112,6 @@ sdt_dns_A(SDT_STATE *ss, char *buf, ssize_t n)
if (n < 1)
return (-1);
- (void)memset(dn, 0, sizeof(dn));
- (void)memset(query, 0, sizeof(query));
- (void)memset(pkt, 0, sizeof(pkt));
-
nonce = (u_int16_t)arc4random();
/* Base32 encode the buffer and lowercase the result */
@@ -158,16 +154,14 @@ sdt_dns_A(SDT_STATE *ss, char *buf, ssize_t n)
char *
sdt_dns_poll(SDT_STATE *ss, size_t *len)
{
- char query[NS_MAXDNAME];
- char pkt[NS_PACKETSZ];
+ char query[NS_MAXDNAME] = {0};
+ char pkt[NS_PACKETSZ] = {0};
char *buf = NULL;
int buflen = 0;
u_int16_t nonce = 0;
- (void)memset(pkt, 0, sizeof(pkt));
-
nonce = (u_int16_t)arc4random();
switch (ss->protocol) {
@@ -320,7 +314,7 @@ sdt_dns_dec_CNAME(SDT_STATE *ss, u_char *data, u_int16_t *n)
{
char *p = NULL;
char *buf = NULL;
- char b32[NS_PACKETSZ];
+ char b32[NS_PACKETSZ] = {0};
IS_NULL(buf = calloc(NS_PACKETSZ, 1));
View
@@ -183,9 +183,9 @@ sds_print_forward(SDS_STATE *ss)
void
sds_timestamp(void)
{
- char outstr[200];
+ char outstr[200] = {0};
time_t t;
- struct tm *tmp;
+ struct tm *tmp = NULL;
t = time(NULL);
tmp = localtime(&t);
View
@@ -240,7 +240,7 @@ sds_dns_enc_TXT(void *state, void *packet)
SDS_STATE *ss = (SDS_STATE *)ss;
SDS_PKT *pkt = (SDS_PKT *)packet;
- char b64[NS_PACKETSZ];
+ char b64[NS_PACKETSZ] = {0};
struct dns_txtrec txt;
ssize_t len = 0;
size_t t = 0;
@@ -351,12 +351,11 @@ sds_dns_enc_NULL(void *state, void *packet)
SDS_STATE *ss = (SDS_STATE *)ss;
SDS_PKT *pkt = (SDS_PKT *)packet;
- char b64[NS_PACKETSZ];
+ char b64[NS_PACKETSZ] = {0};
size_t len = 0;
NULL_RESPONSE(pkt);
- (void)memset(&b64, 0, sizeof(b64));
len = BASE64_LENGTH(pkt->buflen);
base64_encode(pkt->buf, pkt->buflen, b64, sizeof(b64)-1);
View
@@ -125,8 +125,8 @@ sds_io_open(SDS_STATE *ss, SDS_PKT *pkt)
#ifdef HAVE_SETSOCKOPT
int onoff = 1;
#endif /* HAVE_SETSOCKOPT */
- char src[INET_ADDRSTRLEN];
- char dst[INET_ADDRSTRLEN];
+ char src[INET_ADDRSTRLEN] = {0};
+ char dst[INET_ADDRSTRLEN] = {0};
if ( (sc = sds_io_alloc(ss, pkt)) == NULL)
return (NULL);

0 comments on commit 29bb20d

Please sign in to comment.