greenbone / openvas-scanner

This repository contains the scanner component for Greenbone Community Edition.
https://greenbone.github.io/docs/
GNU General Public License v2.0
3.37k stars 623 forks source link

build fail on arch "linux/arm/v7" aka 32bit arm #1520

Closed immauss closed 1 year ago

immauss commented 1 year ago

Expected behavior

Build finishes on all architectures

Actual behavior

Build completes on amd64 & arm64, but fails on arm/v7(armhf) with:

In file included from /usr/include/glib-2.0/glib.h:62,
                 from /build/openvas-scanner-22.7.6/src/../misc/scanneraux.h:14,
                 from /build/openvas-scanner-22.7.6/src/attack.h:16,
                 from /build/openvas-scanner-22.7.6/src/attack.c:13:
/build/openvas-scanner-22.7.6/src/attack.c: In function ‘apply_hosts_reverse_lookup_preferences’:
/build/openvas-scanner-22.7.6/src/attack.c:1098:16: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]     
 1098 |       g_debug ("reverse_lookup_unify: Skipped %lu host(s).", excluded->count);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~
      |                                                                      |
      |                                                                      size_t {aka unsigned int}
/usr/include/glib-2.0/glib/gmessages.h:346:32: note: in definition of macro ‘g_debug’
  346 |                                __VA_ARGS__)
      |                                ^~~~~~~~~~~
/build/openvas-scanner-22.7.6/src/attack.c:1098:49: note: format string is defined here
 1098 |       g_debug ("reverse_lookup_unify: Skipped %lu host(s).", excluded->count);

Steps to reproduce

Follow normal build directions on an armhf CPU or via qemu. ( I'm using my container build.)

GVM versions

gvmd=v23.0.1 gvm_libs=v22.7.3 openvas=v22.7.6 openvas_smb=v22.5.4 notus_scanner=v22.6.0 gsa=v22.8.1 gsad=v22.7.0 ospd=v21.4.4 ospd_openvas=v22.6.1 pg_gvm=v22.6.1 python_gvm=v23.10.1 gvm_tools=v23.10.0 greenbone_feed_sync=v23.10.0

Environment

Utilzining build process from: https://github.com/immauss/openvas

The Problem

The problem is the differing stdlib.h definition of size_t On the armhf:

root@cb1a1fab798b:/mnt# echo '#include <stdlib.h>' | cpp -I/usr/include  | grep "^typedef.*size_t"
typedef unsigned int size_t;

On the AMD64:

/usr/include $ echo '#include <stdlib.h>' | cpp -I/usr/include  | grep "^typedef.*size_t"                                                          
typedef long unsigned int size_t;

I'm not sure what the best way to handle this is in the code.

For my build, I'm just checking the arch and substituting %lu for %i. I guess I also should hope that no one is using a really long host exclude list ..... :) Builds using %i instead of %lu complete successfully.

immauss commented 1 year ago

I have not yet had time to go back to diff the code, but this started with either 22.6.0 or 22.6.1.

nichtsfrei commented 1 year ago

Hello,

thank you for reporting this issue.

Unfortunately linux/arm/v7 is an unsupported architecture, therefore I don't have the capacity to test it myself.

But theoretically https://github.com/greenbone/openvas-scanner/pull/1522 should fix that issue.