1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00
Martin Schwenke a2590298b0 util: CID 1499409: Memory - corruptions (OVERLAPPING_COPY)
This is quite bizarre:

*** CID 1499409:  Memory - corruptions  (OVERLAPPING_COPY)
/lib/util/debug.c: 1742 in dbghdrclass()
1736     					 sizeof(tvbuf.buf),
1737     					 "%ld seconds since the Epoch", (long)t);
1738     			}
1739     		}
1740
1741     		ensure_hostname();
>>>     CID 1499409:  Memory - corruptions  (OVERLAPPING_COPY)
>>>     In the call to function "snprintf", the object pointed to by argument "state.hostname" may overlap with the object pointed to by argument "state.header_str".
1742     		state.hs_len = snprintf(state.header_str,
1743     					sizeof(state.header_str),
1744     					"%s %s %s[%u]: ",
1745     					tvbuf.buf,
1746     					state.hostname,
1747     					state.prog_name,

Coverity doesn't explicitly say so but the only way this can happen is
if state.hostname is not NUL-terminated within its declared length.
ensure_hostname() and debug_set_hostname() ensure NUL-termination, but
the caching effect of ensure_hostname() probably stops Coverity from
being certain about anything.

Try making Coverity happy by using a precision to limit the number of
characters from hostname that can be used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Feb 22 00:17:12 UTC 2022 on sn-devel-184
2022-02-22 00:17:11 +00:00
..
2016-11-16 12:41:09 +01:00
2016-05-04 01:28:23 +02:00
2016-05-04 01:28:23 +02:00
2021-04-27 13:24:35 +00:00
2021-12-15 03:41:32 +00:00
2021-12-15 03:41:32 +00:00
2021-11-01 06:37:32 +00:00
2017-04-18 22:54:15 +02:00
2017-11-20 21:41:14 +01:00
2016-06-07 14:34:10 +02:00
2022-02-07 19:58:57 +00:00
2021-12-15 19:32:30 +00:00
2021-10-08 19:28:31 +00:00
2017-03-20 12:20:08 +01:00
2015-07-07 23:51:23 +02:00
2019-09-17 22:49:36 +00:00
2021-12-13 16:22:28 +00:00
2018-11-30 08:12:31 +01:00
2021-04-19 18:18:31 +00:00
2015-10-13 01:23:07 +02:00
2021-10-08 19:28:32 +00:00
2021-10-08 19:28:32 +00:00
2015-02-13 23:32:07 +01:00
2015-07-07 23:51:23 +02:00
2015-07-07 23:51:23 +02:00
2021-04-19 19:07:01 +00:00
2019-10-02 08:01:40 +00:00
2019-01-28 15:44:18 +01:00
2019-08-07 06:07:28 +00:00
2014-12-07 00:12:07 +01:00
2022-01-05 01:02:38 +00:00
2020-05-15 13:18:38 +00:00
2017-03-28 17:45:19 +02:00
2021-01-25 09:48:09 +00:00
2021-10-08 19:28:31 +00:00
2021-05-11 22:56:37 +00:00
2021-05-11 22:56:37 +00:00
2022-01-24 15:25:36 +00:00
2022-01-24 15:25:36 +00:00

This directory contains libutil (until we can think of a better name)

The idea is that this library contains simple but useful data structures 
and support functions that are generally useful; not just for Samba but for 
other projects as well. Functions here should not depend on any external 
libraries, just on libc (perhaps partially provided by libreplace).