aboutsummaryrefslogtreecommitdiff
path: root/kms/server
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-05-09 16:17:38 +0200
committerdec05eba <dec05eba@protonmail.com>2024-05-09 16:17:38 +0200
commitf1eb8934930d0bb5e4f64ce24ca9971f0655c04f (patch)
treed1f21120dcca846d21b2a3031bee22f174693c56 /kms/server
parent447b5d0f0ba9ea34b90acd8d6e23005f15f1c242 (diff)
Proper strncpy null termination
Diffstat (limited to 'kms/server')
-rw-r--r--kms/server/kms_server.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kms/server/kms_server.c b/kms/server/kms_server.c
index 09deaab..2eaa1ed 100644
--- a/kms/server/kms_server.c
+++ b/kms/server/kms_server.c
@@ -379,7 +379,7 @@ static double clock_get_monotonic_seconds(void) {
return (double)ts.tv_sec + (double)ts.tv_nsec * 0.000000001;
}
-static void strncpy_safe(char *dst, const char *src, int len) {
+static void string_copy(char *dst, const char *src, int len) {
int src_len = strlen(src);
int min_len = src_len;
if(len - 1 < min_len)
@@ -444,7 +444,7 @@ int main(int argc, char **argv) {
while(clock_get_monotonic_seconds() - start_time < connect_timeout_sec) {
struct sockaddr_un remote_addr = {0};
remote_addr.sun_family = AF_UNIX;
- strncpy_safe(remote_addr.sun_path, domain_socket_path, sizeof(remote_addr.sun_path));
+ string_copy(remote_addr.sun_path, domain_socket_path, sizeof(remote_addr.sun_path));
// TODO: Check if parent disconnected
if(connect(socket_fd, (struct sockaddr*)&remote_addr, sizeof(remote_addr.sun_family) + strlen(remote_addr.sun_path)) == -1) {
if(errno == ECONNREFUSED || errno == ENOENT) {