From: claudio Date: Thu, 25 Aug 2022 16:49:18 +0000 (+0000) Subject: Use memset() and memcpy() instead of bzero() or bcopy(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e479af8fa4f6cc7278dd6555d8733e04e4b415bd;p=openbsd Use memset() and memcpy() instead of bzero() or bcopy(). In one case use memmove() since the operation is done on the same memory buffer and may overlap. OK tb@ --- diff --git a/usr.sbin/bgplgd/qs.c b/usr.sbin/bgplgd/qs.c index dca907c76b8..2356a889653 100644 --- a/usr.sbin/bgplgd/qs.c +++ b/usr.sbin/bgplgd/qs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qs.c,v 1.1 2022/06/28 16:11:30 claudio Exp $ */ +/* $OpenBSD: qs.c,v 1.2 2022/08/25 16:49:18 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker * @@ -148,7 +148,7 @@ valid_prefix(char *str) p[0] = '\0'; } - bzero(&hints, sizeof(hints)); + memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_NUMERICHOST; diff --git a/usr.sbin/bgplgd/slowcgi.c b/usr.sbin/bgplgd/slowcgi.c index 02ef8a8d30d..ed76bcad0d7 100644 --- a/usr.sbin/bgplgd/slowcgi.c +++ b/usr.sbin/bgplgd/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.3 2022/08/12 13:24:30 claudio Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.4 2022/08/25 16:49:18 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -387,7 +387,7 @@ slowcgi_listen(char *path, struct passwd *pw) 0)) == -1) lerr(1, "slowcgi_listen: socket"); - bzero(&sun, sizeof(sun)); + memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= sizeof(sun.sun_path)) @@ -681,7 +681,7 @@ slowcgi_request(int fd, short events, void *arg) /* Make space for further reads */ if (c->buf_len > 0) { - bcopy(c->buf + c->buf_pos, c->buf, c->buf_len); + memmove(c->buf, c->buf + c->buf_pos, c->buf_len); c->buf_pos = 0; } return; @@ -789,11 +789,11 @@ parse_params(uint8_t *buf, uint16_t n, struct request *c, uint16_t id) return; } - bcopy(buf, env_entry->key, name_len); + memcpy(env_entry->key, buf, name_len); buf += name_len; n -= name_len; env_entry->key[name_len] = '\0'; - bcopy(buf, env_entry->val, val_len); + memcpy(env_entry->val, buf, val_len); buf += val_len; n -= val_len; env_entry->val[val_len] = '\0';