nayutaco / ptarmigan

Lightning Network (BOLT)
Apache License 2.0
132 stars 19 forks source link

Error on compiling `ln_db_lmdb.c`. #1605

Closed cryptcoin-junkey closed 4 years ago

cryptcoin-junkey commented 4 years ago

I couldn't build Ptarmigan with the Dockerfile (similar to the build instruction). I suspect this was caused by strict checkings on newer GNU C compiler.

FROM ubuntu:18.10

RUN apt-get update
RUN apt-get install -y git autoconf pkg-config build-essential libtool python3 wget jq bc

RUN git clone https://github.com/nayutaco/ptarmigan.git
WORKDIR ptarmigan
RUN make full
error messages ``` Compiling C file: ln_db_lmdb.c ln_db_lmdb.c: In function 'ln_lmdb_set_home_dir': ln_db_lmdb.c:4195:31: error: '%s' directive output may be truncated writing 2 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] ln_db_lmdb.c:756:10: if (!set_path(mPath, sizeof(mPath), path, M_DB_DIR)) return false; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ln_db_lmdb.c:4195:31: snprintf(pPath, Size, "%s/%s", pDir, pName); ^~ In file included from /usr/include/stdio.h:873, from ln_db_lmdb.c:25: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output between 4 and 4099 bytes into a destination of size 4096 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ln_db_lmdb.c:4195:31: error: '%s' directive output may be truncated writing 7 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] ``` and more errors.
cryptcoin-junkey commented 4 years ago

After replacing to debian:9 image, builds are done with no error.

- FROM ubuntu:18:10
+ FROM debian:9
nayuta-ueno commented 4 years ago

Thank you. I fix this on gcc-8.

$ gcc --version
gcc (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0
cryptcoin-junkey commented 4 years ago

@nayuta-ueno I checked this issue was fixed on the head of master branch. I close it. Thanks for the improvement.