diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-05-09 16:17:38 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-05-09 16:17:38 +0200 |
commit | f1eb8934930d0bb5e4f64ce24ca9971f0655c04f (patch) | |
tree | d1f21120dcca846d21b2a3031bee22f174693c56 /kms/client | |
parent | 447b5d0f0ba9ea34b90acd8d6e23005f15f1c242 (diff) |
Proper strncpy null termination
Diffstat (limited to 'kms/client')
-rw-r--r-- | kms/client/kms_client.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c index 57c6ccf..1c8f634 100644 --- a/kms/client/kms_client.c +++ b/kms/client/kms_client.c @@ -127,7 +127,7 @@ static bool create_socket_path(char *output_path, size_t output_path_size) { return true; } -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) @@ -232,7 +232,7 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { } local_addr.sun_family = AF_UNIX; - strncpy_safe(local_addr.sun_path, self->initial_socket_path, sizeof(local_addr.sun_path)); + string_copy(local_addr.sun_path, self->initial_socket_path, sizeof(local_addr.sun_path)); const mode_t prev_mask = umask(0000); const int bind_res = bind(self->initial_socket_fd, (struct sockaddr*)&local_addr, sizeof(local_addr.sun_family) + strlen(local_addr.sun_path)); |