Skip to content

Conversation

@hackman
Copy link

@hackman hackman commented Apr 2, 2024

This pull request is aimed at removing some compilation warnings found on Ubuntu 22.04 and Slackware 14 and 15.

Marian Marinov added 4 commits April 1, 2024 22:25
This commit fixes the following compilation warning:

  rtt.c: In function ‘rtt’:
  rtt.c:43:17: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   43 |                 for (i=0; i<TABLESIZE; i++)
      |                 ^~~
  rtt.c:48:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   48 |                         if (i != TABLESIZE)
      |                         ^~

Signed-off-by: Marian Marinov <mm@whc.ca>
This commit fixes the following compilation warning:
  listen.c: In function ‘listenmain’:
  listen.c:77:25: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   77 |                         write(stdoutFD, p, size-(p-ip_packet));
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Marian Marinov <mm@whc.ca>
This commit fixes the following compilation warning:
  gcc -c -O2 -Wall    -g  sendicmp.c
  In file included from /usr/include/string.h:535,
                 from sendicmp.c:19:
  In function ‘memcpy’,
    inlined from ‘send_icmp_other’ at sendicmp.c:256:2:
  /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: warning: ‘__builtin_memcpy’ forming offset [20, 27] is out of the bounds [0, 20] of object ‘icmp_ip’ with type ‘struct myiphdr’ [-Warray-bounds]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
  sendicmp.c: In function ‘send_icmp_other’:
  sendicmp.c:197:24: note: ‘icmp_ip’ declared here
  197 |         struct myiphdr icmp_ip;
      |                        ^~~~~~~

Copying out of bounds may result in nasty security exploits.
This commit proposes a fix for the following compilation warning.
The warning is reported, because the string is initialized with
NULL values, but the strncpy() is overwriting the full length of
the string, which actually overwrites the last NULL value too.

  In file included from /usr/include/string.h:535,
                 from gethostname.c:19:
  In function ‘strncpy’,
    inlined from ‘get_hostname’ at gethostname.c:37:2:
  /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: ‘__builtin_strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncpy’,
    inlined from ‘get_hostname’ at gethostname.c:46:2:
  /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: ‘__builtin_strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant