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

compiling tunefs.ocfs2/op_query.c failed with -Werror=format-security #18

Open
cheese opened this issue Sep 3, 2017 · 8 comments
Open

Comments

@cheese
Copy link

cheese commented Sep 3, 2017

at commit 401407e
Fedora 26
gcc-7.1.1-3.fc26.x86_64

$ cd tunefs.ocfs2
$ gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -pipe    -I../include -Iinclude  -DVERSION=\"1.8.5\"  -MD -MP -MF ./.op_query.d -o op_query.o -c op_query.c 
op_query.c: In function ‘query_run’:
op_query.c:327:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('B', handle_blocksize, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:327:50: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('B', handle_blocksize, handle_arginfo);
                                                  ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:328:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('T', handle_clustersize, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:328:52: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('T', handle_clustersize, handle_arginfo);
                                                    ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:329:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('N', handle_numslots, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:329:49: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('N', handle_numslots, handle_arginfo);
                                                 ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:330:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('R', handle_rootdir, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:330:48: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('R', handle_rootdir, handle_arginfo);
                                                ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:331:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('Y', handle_sysdir, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:331:47: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('Y', handle_sysdir, handle_arginfo);
                                               ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:332:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('P', handle_clustergroup, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:332:53: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('P', handle_clustergroup, handle_arginfo);
                                                     ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:334:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('V', handle_label, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:334:46: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('V', handle_label, handle_arginfo);
                                              ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:335:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('U', handle_uuid, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:335:45: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('U', handle_uuid, handle_arginfo);
                                             ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:337:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('M', handle_compat, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:337:47: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('M', handle_compat, handle_arginfo);
                                               ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:338:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('H', handle_incompat, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:338:49: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('H', handle_incompat, handle_arginfo);
                                                 ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:339:2: warning: ‘register_printf_function’ is deprecated [-Wdeprecated-declarations]
  register_printf_function('O', handle_ro_compat, handle_arginfo);
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: declared here
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:339:50: warning: passing argument 3 of ‘register_printf_function’ from incompatible pointer type [-Wincompatible-pointer-types]
  register_printf_function('O', handle_ro_compat, handle_arginfo);
                                                  ^~~~~~~~~~~~~~
In file included from op_query.c:21:0:
/usr/include/printf.h:105:12: note: expected ‘int (*)(const struct printf_info *, size_t,  int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *)}’ but argument is of type ‘int (*)(const struct printf_info *, size_t,  int *, int *) {aka int (*)(const struct printf_info *, long unsigned int,  int *, int *)}’
 extern int register_printf_function (int __spec, printf_function __func,
            ^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:342:2: error: format not a string literal and no format arguments [-Werror=format-security]
  fprintf(stdout, fmt);
  ^~~~~~~
cc1: some warnings being treated as errors
@josephhz
Copy link
Collaborator

josephhz commented Sep 4, 2017

Please refer commit 3e692a9 for details.

@cheese
Copy link
Author

cheese commented Sep 4, 2017

The commit above does not deal with this issue. The failed source line is:

fprintf(stdout, fmt);

Others are just warnings.

@vvidic
Copy link
Contributor

vvidic commented Jan 25, 2018

One workaround for this would be to use a dummy argument:

fprintf(stdout, fmt, "dummy");

@cheese
Copy link
Author

cheese commented Jan 29, 2018

A good catch!

@HHHSong
Copy link

HHHSong commented Aug 13, 2019

fprintf(stdout, "%s", fmt);

@vvidic
Copy link
Contributor

vvidic commented Aug 13, 2019

fprintf(stdout, "%s", fmt);

But fmt might contain specifies registered by ocfs2 that would not print this way.

HHHSong referenced this issue in HHHSong/ocfs2-tools Aug 13, 2019
Signed-off-by: gaosong <[email protected]>
@HHHSong
Copy link

HHHSong commented Aug 13, 2019

-Wformat-security is enabled by default for C, C++, ObjC on high version GCC or high version system. To disable, use -Wno-format-security. I have compiled successfully in rhel8.

@vvidic
Copy link
Contributor

vvidic commented Aug 14, 2019 via email

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

4 participants