Project

General

Profile

Issue #3131

How to repair unrecognized characters in formatted output functions?

Added by Bin Liu about 1 month ago. Updated 13 days ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Category:
-
Affected version:
5.5.0
Resolution:

Description

Hi,
When I compile strongswan source code, the compiler produces the following warnings:

timeattack.c: In function ‘timeattack’:
timeattack.c:153:35: warning: unknown conversion type character ‘b’ in format [-Wformat=]
printf("attack successful with %b\n", test, dlen);
^
timeattack.c:153:10: warning: too many arguments for format [-Wformat-extra-args]
printf("attack successful with %b\n", test, dlen);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
timeattack.c:156:30: warning: unknown conversion type character ‘b’ in format [-Wformat=]
printf("attack failed with %b\n", test, dlen);
^
timeattack.c:156:9: warning: too many arguments for format [-Wformat-extra-args]
printf("attack failed with %b\n", test, dlen);
^~~~~~~~~~~~~~~~~~~~~~~
timeattack.c: In function ‘attack_memeq’:
timeattack.c:225:30: warning: unknown conversion type character ‘b’ in format [-Wformat=]
fprintf(stderr, "attacking %b\n", exp, sizeof(exp));
^
timeattack.c:225:18: warning: too many arguments for format [-Wformat-extra-args]
fprintf(stderr, "attacking %b\n", exp, sizeof(exp));
^~~~~~~~~~~~~~
timeattack.c: In function ‘attack_chunk’:
timeattack.c:267:30: warning: unknown conversion type character ‘b’ in format [-Wformat=]
fprintf(stderr, "attacking %b\n", exp, sizeof(exp));
^
timeattack.c:267:18: warning: too many arguments for format [-Wformat-extra-args]
fprintf(stderr, "attacking %b\n", exp, sizeof(exp));
^~~~~~~~~~~~~~
timeattack.c: In function ‘attack_aeads’:
timeattack.c:300:35: warning: unknown conversion type character ‘N’ in format [-Wformat=]
fprintf(stderr, "creating AEAD %N failed\n",
^
timeattack.c:300:19: warning: too many arguments for format [-Wformat-extra-args]
fprintf(stderr, "creating AEAD %N failed\n",
^~~~~~~~~~~~~~~~~~~~~~~~~
timeattack.c:317:30: warning: unknown conversion type character ‘b’ in format [-Wformat=]
fprintf(stderr, "attacking %b\n", buf, aead->get_icv_size(aead));
^
timeattack.c:317:18: warning: too many arguments for format [-Wformat-extra-args]
fprintf(stderr, "attacking %b\n", buf, aead->get_icv_size(aead));
^~~~~~~~~~~~~~

The compiler I used was aarch64-linux-gnu-gcc,After the compilation passes, there will be a segment error when running on the target machine.
core dump as fallows:

Program terminated with signal SIGSEGV, Segmentation fault.
#0 builder_filter (null=0xaaaab076b378 <parse+108>, entry=0xfffff6854500,
type=0xb9401be2a9010fea, dummy1=0xa9410c42a9000fe1, subtype=0xf9400443f9400021)
at credentials/credential_factory.c:174
174 credentials/credential_factory.c: No such file or directory.
(gdb) bt
#0 builder_filter (null=0xaaaab076b378 <parse+108>, entry=0xfffff6854500,
type=0xb9401be2a9010fea, dummy1=0xa9410c42a9000fe1, subtype=0xf9400443f9400021)
at credentials/credential_factory.c:174
#1 0x0000aaaab076b2d8 in resolve_also (sections=0xaaaabe94f0c0)
at parser/conf_parser.c:606
#2 0x0000aaaab076b378 in parse (this=0xaaaabe94ef70) at parser/conf_parser.c:623
#3 0x0000aaaab0767868 in confread_load (file=0xaaaab07711b8 "/mnt/data/ipsec/ipsec.conf")
at confread.c:697
#4 0x0000aaaab0764210 in main (argc=3, argv=0xfffff68548b8) at starter.c:573

How to solve it? Thanks!

History

#1 Updated by Noel Kuntze about 1 month ago

  • Status changed from New to Feedback

Looks like you screwed up the includes. Those format specifiers are processed by custom hooks for printf in the strongSwan source code.

#2 Updated by Bin Liu about 1 month ago

The Strongswan version I used was 5.5.0 and errors occurred when compiling 64-bit programs:

/utils/utils/memory.h:99:15: error: 'uintptr_t' undeclared (first use in this function); did you mean '__intptr_t'?

So I followed the previous Bug # 2425 and added the header file "stdint.h" to the src/libstrongswan/utils/utils.h file.Is that the problem?

#3 Updated by Noel Kuntze about 1 month ago

No, that is entirely unrelated.

#4 Updated by Bin Liu about 1 month ago

Only this header file has been changed. Is there any other reason? Does the compiler cause this?

#5 Updated by Bin Liu about 1 month ago

Hi,
I downloaded the same version of the original source code package on the official website, and many of these warrning will also be generated during compilation.
Is there any good way to solve this problem?

#6 Updated by Bin Liu about 1 month ago

My configuration and compilation parameters are as follows:
CONFIGURE_OPTION+=" --enable-frwk-scard"
CONFIGURE_OPTION+=" --enable-eap-aka"
CONFIGURE_OPTION+=" --enable-eap-aka-3gpp"
CONFIGURE_OPTION+=" --enable-error-notify"
CONFIGURE_OPTION+=" --enable-lookip"
CONFIGURE_OPTION+=" --disable-ikev1"
CONFIGURE_OPTION+=" --disable-vici"
CONFIGURE_OPTION+=" --disable-swanctl"
CONFIGURE_OPTION+=" --with-random-device=/dev/urandom"

COMPILE_OPTION=" --host=aarch64-linux-gnu "
CC="/usr/bin/aarch64-linux-gnu-gcc" CFLAGS="-fno-strict-aliasing -g" ./configure --prefix=$INSTALL_PATH --sysconfdir=$DATA_PATH $COMPILE_OPTION $CONFIGURE_OPTION
make -C $SRC_PATH "PLT_ARCH=arm"

#7 Updated by Tobias Brunner 13 days ago

The printf-related compile warnings have nothing to do with the segmentation fault. The latter's backtrace looks very strange. Maybe you are mixing incompatible library/binary versions. Also, 5.5.0 is quite old.

Also available in: Atom PDF