Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler-warning for strncpy of parsing "platform" parameter #3

Closed
SvenRoederer opened this issue Jul 26, 2020 · 3 comments
Closed

Comments

@SvenRoederer
Copy link
Contributor

SvenRoederer commented Jul 26, 2020

kernel2minor.c: In function 'main':
kernel2minor.c:617:17: warning: 'strncpy' specified bound 9 equals destination size [-Wstringop-truncation]
       case 'p': strncpy(platform_name, optarg, sizeof(platform_name)); break;
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Seems to be caused by copying optarg, which has an undetermined length.

@adron-s
Copy link
Owner

adron-s commented Jul 26, 2020

Thank you for your comment. I seems to have corrected the code.

@adron-s adron-s closed this as completed Jul 26, 2020
@SvenRoederer
Copy link
Contributor Author

I was also checking around the "ib_var_tmp_buf" definition but wasn't sure if extending would have been the solution.

Thanks for your work in 062eed9.

@SvenRoederer
Copy link
Contributor Author

just found time to build the new version, but still a very similar warning:

In file included from kernel2minor.c:27:
kernel2minor.c: In function 'do_pack':
kernel2minor.h:32:2: warning: 'strncpy' output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(d, s, sizeof(d) - 1); \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel2minor.c:485:5: note: in expansion of macro 'strcpy_safe'
     strcpy_safe(ib_var_tmp_buf, "MIKROTIK");
     ^~~~~~~~~~~

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

No branches or pull requests

2 participants