From 77686bf8321b24a25d7369acba1829c29b3eb54f Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Thu, 16 Jan 2020 11:49:13 +0000 Subject: [PATCH] Fix cppcheck 1.89+1.90 warnings --- sesman/chansrv/chansrv_fuse.c | 2 ++ sesman/chansrv/devredir.c | 24 +++--------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 7d8d1a22..b57cc662 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -2537,6 +2537,8 @@ static char *get_name_for_entry_in_parent(fuse_ino_t parent, const char *name) strlen(result) + 1 + strlen(name) + 1); if (p == NULL) { + /* See cppcheck trac #9292 and #9437 */ + /* cppcheck-suppress doubleFree symbolName=result */ free(result); result = NULL; } diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 49b7ce32..6455746b 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -185,28 +185,10 @@ devredir_init(void) { struct stream *s; int bytes; - int fd; - - union _u - { - tui32 clientID; - char buf[4]; - } u; + tui32 clientID; /* get a random number that will act as a unique clientID */ - if ((fd = open("/dev/urandom", O_RDONLY)) != -1) - { - if (read(fd, u.buf, 4) != 4) - { - } - close(fd); - } - else - { - /* /dev/urandom did not work - use address of struct s */ - tui64 u64 = (tui64) (tintptr) &s; - u.clientID = (tui32) u64; - } + g_random((char *) &clientID, sizeof(clientID)); /* setup stream */ xstream_new(s, 1024); @@ -216,7 +198,7 @@ devredir_init(void) xstream_wr_u16_le(s, PAKID_CORE_SERVER_ANNOUNCE); xstream_wr_u16_le(s, 0x0001); /* server major ver */ xstream_wr_u16_le(s, 0x000C); /* server minor ver - pretend 2 b Win 7 */ - xstream_wr_u32_le(s, u.clientID); /* unique ClientID */ + xstream_wr_u32_le(s, clientID); /* unique ClientID */ /* send data to client */ bytes = xstream_len(s);