fixed some further snprintf warns

fixes warnings with Xcode 14.3 as in previous commit

+ allocate +1 in Log_output buffer - snprintf(MULL, 0...) returns number
  of bytes without terminating '\0'. std::string storage isn't guaranteed
  to be NULL-terminated (std::string("").at(0) throws an exception). The
  buffer is somewhere preallocated 256 which prevents problem but it's
  better not to rely upon it.
+ comment out some unused function in LDGM that also triggered the
  warning but looked a bit suspicious so it was not clear how to fix
This commit is contained in:
Martin Pulec
2023-04-12 09:01:54 +02:00
parent e1dc81b55a
commit 602095e38a
9 changed files with 29 additions and 22 deletions

View File

@@ -3,7 +3,7 @@
* @author Martin Pulec <pulec@cesnet.cz>
*/
/*
* Copyright (c) 2013-2021 CESNET, z. s. p. o.
* Copyright (c) 2013-2023 CESNET, z. s. p. o.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -701,7 +701,7 @@ static void process_messages(struct control_state *s)
uint16_t port = socket_get_recv_port(s->socket_fd);
if (port) {
char port_str[6];
sprintf(port_str, "%hu", port);
snprintf(port_str, sizeof port_str, "%hu", port);
r = new_response(RESPONSE_OK, port_str);
} else {
r = new_response(RESPONSE_INT_SERV_ERR, "get_recv_port");