diff options
76 files changed, 198 insertions, 223 deletions
diff --git a/apps/opt.c b/apps/opt.c index fbe4c4bebc..3e2831cc1f 100644 --- a/apps/opt.c +++ b/apps/opt.c @@ -795,7 +795,7 @@ void opt_help(const OPTIONS *list) } /* Pad out prefix */ - memset(start, ' ', sizeof start - 1); + memset(start, ' ', sizeof(start) - 1); start[sizeof start - 1] = '\0'; if (o->name == OPT_MORE_STR) { @@ -821,7 +821,7 @@ void opt_help(const OPTIONS *list) if ((int)(p - start) >= MAX_OPT_HELP_WIDTH) { *p = '\0'; BIO_printf(bio_err, "%s\n", start); - memset(start, ' ', sizeof start); + memset(start, ' ', sizeof(start)); } start[width] = '\0'; BIO_printf(bio_err, "%s %s\n", start, help); diff --git a/apps/s_apps.h b/apps/s_apps.h index cf3026de29..c8069a0f6e 100644 --- a/apps/s_apps.h +++ b/apps/s_apps.h @@ -144,7 +144,7 @@ typedef fd_mask fd_set; # define FD_SET(n, p) (*(p) |= (1 << ((n) % NFDBITS))) # define FD_CLR(n, p) (*(p) &= ~(1 << ((n) % NFDBITS))) # define FD_ISSET(n, p) (*(p) & (1 << ((n) % NFDBITS))) -# define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p))) +# define FD_ZERO(p) memset((p), 0, sizeof(*(p))) #endif #define PORT 4433 diff --git a/apps/s_socket.c b/apps/s_socket.c index bba8e0808f..1ca0d3a94a 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -252,7 +252,7 @@ static int init_client_ip(int *sock, const unsigned char ip[4], int port, if (!ssl_sock_init()) return (0); - memset((char *)&them, 0, sizeof(them)); + memset(&them, 0, sizeof(them)); them.sin_family = AF_INET; them.sin_port = htons((unsigned short)port); addr = (unsigned long) @@ -308,7 +308,7 @@ int init_client_unix(int *sock, const char *server) return (0); } - memset((char *)&them, 0, sizeof(them)); + memset(&them, 0, sizeof(them)); them.sun_family = AF_UNIX; strcpy(them.sun_path, server); @@ -410,7 +410,7 @@ static int init_server_long(int *sock, int port, char *ip, int type) if (!ssl_sock_init()) return (0); - memset((char *)&server, 0, sizeof(server)); + memset(&server, 0, sizeof(server)); server.sin_family = AF_INET; server.sin_port = htons((unsigned short)port); if (ip == NULL) @@ -475,7 +475,7 @@ static int init_server_unix(int *sock, const char *path) if (s == INVALID_SOCKET) goto err; - memset((char *)&server, 0, sizeof(server)); + memset(&server, 0, sizeof(server)); server.sun_family = AF_UNIX; strcpy(server.sun_path, path); @@ -518,7 +518,7 @@ static int do_accept(int acc_sock, int *sock, char **host) redoit: # endif - memset((char *)&from, 0, sizeof(from)); + memset(&from, 0, sizeof(from)); len = sizeof(from); /* * Note: under VMS with SOCKETSHR the fourth parameter is currently of diff --git a/crypto/LPdir_unix.c b/crypto/LPdir_unix.c index 3a14da19b1..1428cd16c6 100644 --- a/crypto/LPdir_unix.c +++ b/crypto/LPdir_unix.c @@ -83,7 +83,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) errno = ENOMEM; return 0; } - memset(*ctx, '\0', sizeof(**ctx)); + memset(*ctx, 0, sizeof(**ctx)); (*ctx)->dir = opendir(directory); if ((*ctx)->dir == NULL) { diff --git a/crypto/LPdir_vms.c b/crypto/LPdir_vms.c index 1e8f9e7d61..362918dae3 100644 --- a/crypto/LPdir_vms.c +++ b/crypto/LPdir_vms.c @@ -109,7 +109,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) errno = ENOMEM; return 0; } - memset(*ctx, '\0', sizeof(**ctx)); + memset(*ctx, 0, sizeof(**ctx)); strcpy((*ctx)->filespec, directory); strcat((*ctx)->filespec, "*.*;"); diff --git a/crypto/LPdir_win.c b/crypto/LPdir_win.c index 78a796de80..4ff514f885 100644 --- a/crypto/LPdir_win.c +++ b/crypto/LPdir_win.c @@ -74,7 +74,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) errno = ENOMEM; return 0; } - memset(*ctx, '\0', sizeof(**ctx)); + memset(*ctx, 0, sizeof(**ctx)); if (directory[dirlen - 1] != '*') { extdirbuf = (char *)malloc(dirlen + 3); diff --git a/crypto/asn1/a_enum.c b/crypto/asn1/a_enum.c index 4abd80c122..aed3de5fee 100644 --- a/crypto/asn1/a_enum.c +++ b/crypto/asn1/a_enum.c @@ -77,7 +77,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) if (a->length < (int)(sizeof(long) + 1)) { OPENSSL_free(a->data); if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL) - memset((char *)a->data, 0, sizeof(long) + 1); + memset(a->data, 0, sizeof(long) + 1); } if (a->data == NULL) { ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index 68a312b97a..228297803b 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -349,7 +349,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v) if (a->length < (int)(sizeof(long) + 1)) { OPENSSL_free(a->data); if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL) - memset((char *)a->data, 0, sizeof(long) + 1); + memset(a->data, 0, sizeof(long) + 1); } if (a->data == NULL) { ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); diff --git a/crypto/asn1/a_verify.c b/crypto/asn1/a_verify.c index b452999756..5b908f14ce 100644 --- a/crypto/asn1/a_verify.c +++ b/crypto/asn1/a_verify.c @@ -121,11 +121,6 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature, ret = 0; goto err; } - /* - * we don't need to zero the 'ctx' because we just checked public - * information - */ - /* memset(&ctx,0,sizeof(ctx)); */ ret = 1; err: EVP_MD_CTX_cleanup(&ctx); @@ -221,11 +216,6 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ret = 0; goto err; } - /* - * we don't need to zero the 'ctx' because we just checked public - * information - */ - /* memset(&ctx,0,sizeof(ctx)); */ ret = 1; err: EVP_MD_CTX_cleanup(&ctx); diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index c7acb468a6..de70f9b4b2 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -288,8 +288,7 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, if (!ameth) return NULL; - memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD)); - + memset(ameth, 0, sizeof(*ameth)); ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index 39499de591..e3a1ee94da 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -484,7 +484,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) if (!BIO_get_port(p, &port)) goto err; - memset((char *)&server, 0, sizeof(server)); + memset(&server, 0, sizeof(server)); server.sa_in.sin_family = AF_INET; server.sa_in.sin_port = htons(port); addrlen = sizeof(server.sa_in); diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index cde8da3346..48435b09eb 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -140,7 +140,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void) if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) return (NULL); - memset(ret, 0, sizeof(BIO_ACCEPT)); + memset(ret, 0, sizeof(*ret)); ret->accept_sock = INVALID_SOCKET; ret->bind_mode = BIO_BIND_NORMAL; return (ret); diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c index b8fa8288eb..60f58e2d22 100644 --- a/crypto/bio/bss_conn.c +++ b/crypto/bio/bss_conn.c @@ -178,7 +178,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c) case BIO_CONN_S_CREATE_SOCKET: /* now setup address */ - memset((char *)&c->them, 0, sizeof(c->them)); + memset(&c->them, 0, sizeof(c->them)); c->them.sin_family = AF_INET; c->them.sin_port = htons((unsigned short)c->port); l = (unsigned long) @@ -298,7 +298,7 @@ BIO_CONNECT *BIO_CONNECT_new(void) ret->ip[2] = 0; ret->ip[3] = 0; ret->port = 0; - memset((char *)&ret->them, 0, sizeof(ret->them)); + memset(&ret->them, 0, sizeof(ret->them)); return (ret); } diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index fb1564cd12..53d8136d64 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -228,7 +228,7 @@ static int dgram_new(BIO *bi) data = OPENSSL_malloc(sizeof(*data)); if (data == NULL) return 0; - memset(data, 0x00, sizeof(bio_dgram_data)); + memset(data, 0, sizeof(*data)); bi->ptr = data; bi->flags = 0; @@ -395,7 +395,7 @@ static int dgram_read(BIO *b, char *out, int outl) if (out != NULL) { clear_socket_error(); - memset(&sa.peer, 0x00, sizeof(sa.peer)); + memset(&sa.peer, 0, sizeof(sa.peer)); dgram_adjust_rcv_timeout(b); ret = recvfrom(b->num, out, outl, 0, &sa.peer.sa, (void *)&sa.len); if (sizeof(sa.len.i) != sizeof(sa.len.s) && sa.len.i == 0) { @@ -569,7 +569,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_DGRAM_MTU_DISCOVER: # if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) addr_len = (socklen_t) sizeof(addr); - memset((void *)&addr, 0, sizeof(addr)); + memset(&addr, 0, sizeof(addr)); if (getsockname(b->num, &addr.sa, &addr_len) < 0) { ret = 0; break; @@ -600,7 +600,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_DGRAM_QUERY_MTU: # if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU) addr_len = (socklen_t) sizeof(addr); - memset((void *)&addr, 0, sizeof(addr)); + memset(&addr, 0, sizeof(addr)); if (getsockname(b->num, &addr.sa, &addr_len) < 0) { ret = 0; break; @@ -693,7 +693,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) } } else { data->connected = 0; - memset(&(data->peer), 0x00, sizeof(data->peer)); + memset(&data->peer, 0, sizeof(data->peer)); } break; case BIO_CTRL_DGRAM_GET_PEER: @@ -1028,7 +1028,7 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag) # ifdef SCTP_AUTHENTICATION_EVENT # ifdef SCTP_EVENT - memset(&event, 0, sizeof(struct sctp_event)); + memset(&event, 0, sizeof(event)); event.se_assoc_id = 0; event.se_type = SCTP_AUTHENTICATION_EVENT; event.se_on = 1; @@ -1088,7 +1088,7 @@ static int dgram_sctp_new(BIO *bi) data = OPENSSL_malloc(sizeof(*data)); if (data == NULL) return 0; - memset(data, 0x00, sizeof(bio_dgram_sctp_data)); + memset(data, 0, sizeof(*data)); # ifdef SCTP_PR_SCTP_NONE data->prinfo.pr_policy = SCTP_PR_SCTP_NONE; # endif @@ -1149,8 +1149,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl) clear_socket_error(); do { - memset(&data->rcvinfo, 0x00, - sizeof(struct bio_dgram_sctp_rcvinfo)); + memset(&data->rcvinfo, 0, sizeof(data->rcvinfo)); iov.iov_base = out; iov.iov_len = outl; msg.msg_name = NULL; @@ -1229,7 +1228,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl) /* disable sender dry event */ # ifdef SCTP_EVENT - memset(&event, 0, sizeof(struct sctp_event)); + memset(&event, 0, sizeof(event)); event.se_assoc_id = 0; event.se_type = SCTP_SENDER_DRY_EVENT; event.se_on = 0; @@ -1393,7 +1392,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl) * parameters and flags. */ if (in[0] != 23) { - memset(&handshake_sinfo, 0x00, sizeof(struct bio_dgram_sctp_sndinfo)); + memset(&handshake_sinfo, 0, sizeof(handshake_sinfo)); # ifdef SCTP_SACK_IMMEDIATELY handshake_sinfo.snd_flags = SCTP_SACK_IMMEDIATELY; # endif @@ -1433,7 +1432,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl) cmsg->cmsg_type = SCTP_SNDINFO; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndinfo)); sndinfo = (struct sctp_sndinfo *)CMSG_DATA(cmsg); - memset(sndinfo, 0, sizeof(struct sctp_sndinfo)); + memset(sndinfo, 0, sizeof(*sndinfo)); sndinfo->snd_sid = sinfo->snd_sid; sndinfo->snd_flags = sinfo->snd_flags; sndinfo->snd_ppid = sinfo->snd_ppid; @@ -1446,7 +1445,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl) cmsg->cmsg_type = SCTP_PRINFO; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_prinfo)); prinfo = (struct sctp_prinfo *)CMSG_DATA(cmsg); - memset(prinfo, 0, sizeof(struct sctp_prinfo)); + memset(prinfo, 0, sizeof(*prinfo)); prinfo->pr_policy = pinfo->pr_policy; prinfo->pr_value = pinfo->pr_value; msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_prinfo)); @@ -1456,7 +1455,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl) cmsg->cmsg_type = SCTP_SNDRCV; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); sndrcvinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); - memset(sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo)); + memset(sndrcvinfo, 0, sizeof(*sndrcvinfo)); sndrcvinfo->sinfo_stream = sinfo->snd_sid; sndrcvinfo->sinfo_flags = sinfo->snd_flags; # ifdef __FreeBSD__ @@ -1553,7 +1552,7 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr) ret = -1; break; } - memset(authkey, 0x00, sockopt_len); + memset(authkey, 0, sockopt_len); authkey->sca_keynumber = authkeyid.scact_keynumber + 1; # ifndef __FreeBSD__ /* @@ -1750,7 +1749,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b) /* set sender dry event */ # ifdef SCTP_EVENT - memset(&event, 0, sizeof(struct sctp_event)); + memset(&event, 0, sizeof(event)); event.se_assoc_id = 0; event.se_type = SCTP_SENDER_DRY_EVENT; event.se_on = 1; @@ -1773,7 +1772,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b) return -1; /* peek for notification */ - memset(&snp, 0x00, sizeof(union sctp_notification)); + memset(&snp, 0, sizeof(snp)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; @@ -1795,7 +1794,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b) /* if we find a notification, process it and try again if necessary */ while (msg.msg_flags & MSG_NOTIFICATION) { - memset(&snp, 0x00, sizeof(union sctp_notification)); + memset(&snp, 0, sizeof(snp)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; @@ -1820,7 +1819,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b) /* disable sender dry event */ # ifdef SCTP_EVENT - memset(&event, 0, sizeof(struct sctp_event)); + memset(&event, 0, sizeof(event)); event.se_assoc_id = 0; event.se_type = SCTP_SENDER_DRY_EVENT; event.se_on = 0; @@ -1854,7 +1853,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b) (void *)&snp); /* found notification, peek again */ - memset(&snp, 0x00, sizeof(union sct |