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

desktop.c: warning: ‘__builtin_strncpy’ specified bound 24 equals destination size #19

Closed
01micko opened this issue Jun 15, 2024 · 6 comments · Fixed by #20
Closed

Comments

@01micko
Copy link
Contributor

01micko commented Jun 15, 2024

This is using debuild -us -uc -rfakeroot to build labwc-menu-generator

labwc-menu-generator_0.1.0-1_amd64.build (warning)
 dpkg-buildpackage -rfakefoot -us -uc -ui
dpkg-buildpackage: info: source package labwc-menu-generator
dpkg-buildpackage: info: source version 0.1.0-1
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by Mick Mars <[email protected]>
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
 debian/rules clean
dh clean
   dh_auto_clean
	make -j6 clean
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
rm -f -r 'trash directory'.* test-results
rm -f .prove
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_clean
 dpkg-source -b .
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building labwc-menu-generator using existing ./labwc-menu-generator_0.1.0.orig.tar.gz
dpkg-source: info: building labwc-menu-generator in labwc-menu-generator_0.1.0-1.debian.tar.xz
dpkg-source: info: building labwc-menu-generator in labwc-menu-generator_0.1.0-1.dsc
 debian/rules binary
dh binary
   dh_update_autotools_config
   dh_autoreconf
   dh_auto_configure
   dh_auto_build
	make -j6 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o main.o main.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o desktop.o desktop.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o ignore.o ignore.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -o labwc-menu-generator main.o desktop.o ignore.o -Wl,-z,relro `pkg-config --libs glib-2.0`
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_auto_test
	make -j6 check
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
rm -f -r test-results
*** prove ***
t1000.t .. ok
t1001.t .. ok
All tests successful.
Files=2, Tests=2,  0 wallclock secs ( 0.01 usr  0.00 sys +  0.02 cusr  0.00 csys =  0.03 CPU)
Result: PASS
make clean-except-prove-cache
rm -f -r 'trash directory'.* test-results
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   create-stamp debian/debhelper-build-stamp
   dh_prep
   debian/rules override_dh_auto_install
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
dh_auto_configure --buildsystem=meson
	cd obj-x86_64-linux-gnu && DEB_PYTHON_INSTALL_LAYOUT=deb LC_ALL=C.UTF-8 meson setup .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu -Dpython.bytecompile=-1
The Meson build system
Version: 1.4.1
Source dir: /home/mick/Packages/labwc/labwc-menu-generator-0.1.0
Build dir: /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu
Build type: native build
Project name: labwc-menu-generator
Project version: 0.1.0
C compiler for the host machine: cc (gcc 13.2.0 "cc (Debian 13.2.0-25) 13.2.0")
C linker for the host machine: cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1
Run-time dependency glib-2.0 found: YES 2.80.2
Program scdoc found: YES (/usr/bin/scdoc)
Build targets in project: 2

labwc-menu-generator 0.1.0

  User defined options
    buildtype         : plain
    libdir            : lib/x86_64-linux-gnu
    localstatedir     : /var
    prefix            : /usr
    sysconfdir        : /etc
    wrap_mode         : nodownload
    python.bytecompile: -1

Found ninja-1.12.1 at /usr/bin/ninja
meson compile -C obj-x86_64-linux-gnu/
ninja: Entering directory `/home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu'
[1/5] Generating data/labwc-menu-generator.1 with a custom command (wrapped by meson to capture output, to feed input)
[2/5] Compiling C object labwc-menu-generator.p/ignore.c.o
[3/5] Compiling C object labwc-menu-generator.p/main.c.o
[4/5] Compiling C object labwc-menu-generator.p/desktop.c.o
../desktop.c: In function ‘desktop_entries_create’:
../desktop.c:51:9: warning: ‘__builtin_strncpy’ specified bound 24 equals destination size [-Wstringop-truncation]
   51 |         strncpy(llcc, p, sizeof(llcc));
      |         ^
[5/5] Linking target labwc-menu-generator
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu
meson install -C obj-x86_64-linux-gnu/ --destdir=$(pwd)/debian/labwc-menu-generator
ninja: Entering directory `/home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu'
ninja: no work to do.
Installing labwc-menu-generator to /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/debian/labwc-menu-generator/usr/bin
Installing data/labwc-menu-generator.1 to /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/debian/labwc-menu-generator/usr/share/man/man1
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_installdocs
   dh_installchangelogs
   dh_installman
   dh_perl
   dh_link
   dh_strip_nondeterminism
   dh_compress
   dh_fixperms
   dh_missing
   dh_dwz -a
   dh_strip -a
   dh_makeshlibs -a
   dh_shlibdeps -a
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package 'labwc-menu-generator' in '../labwc-menu-generator_0.1.0-1_amd64.deb'.
dpkg-deb: building package 'labwc-menu-generator-dbgsym' in '../labwc-menu-generator-dbgsym_0.1.0-1_amd64.deb'.
 dpkg-genbuildinfo -O../labwc-menu-generator_0.1.0-1_amd64.buildinfo
 dpkg-genchanges -O../labwc-menu-generator_0.1.0-1_amd64.changes
dpkg-genchanges: info: including full source code in upload
 dpkg-source --after-build .
dpkg-buildpackage: info: full upload (original source is included)
Now running lintian labwc-menu-generator_0.1.0-1_amd64.changes ...
Finished running lintian.

I patched it the "debian way"

debian/patches/000-stringop-truncation.patch
From: Mick Mars <[email protected]>
Description: set stringop-truncation patch
--- labwc-menu-generator-0.1.0.orig/desktop.c	2024-06-09 07:55:30.082028828 +1000
+++ labwc-menu-generator-0.1.0/desktop.c	2024-06-15 10:41:43.280054913 +1000
@@ -48,7 +48,7 @@
 	}
 
 	/* ll_CC */
-	strncpy(llcc, p, sizeof(llcc));
+	strncpy(llcc, p, sizeof(llcc) - 1);
 	p = strrchr(llcc, '.');
 	if (p) {
 		*p = '\0';

Ran debuild again

labwc-menu-generator_0.1.0-1_amd64.build (no warnings, not even `lintian` 😝 )
 dpkg-buildpackage -rfakeroot -us -uc -ui
dpkg-buildpackage: info: source package labwc-menu-generator
dpkg-buildpackage: info: source version 0.1.0-1
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by Mick Mars <[email protected]>
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
 debian/rules clean
dh clean
   dh_auto_clean
	make -j6 clean
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
rm -f -r 'trash directory'.* test-results
rm -f .prove
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_clean
 dpkg-source -b .
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building labwc-menu-generator using existing ./labwc-menu-generator_0.1.0.orig.tar.gz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: building labwc-menu-generator in labwc-menu-generator_0.1.0-1.debian.tar.xz
dpkg-source: info: building labwc-menu-generator in labwc-menu-generator_0.1.0-1.dsc
 debian/rules binary
dh binary
   dh_update_autotools_config
   dh_autoreconf
   dh_auto_configure
   dh_auto_build
	make -j6 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o main.o main.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o desktop.o desktop.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o ignore.o ignore.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -o labwc-menu-generator main.o desktop.o ignore.o -Wl,-z,relro `pkg-config --libs glib-2.0`
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_auto_test
	make -j6 check
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
rm -f -r test-results
*** prove ***
t1000.t .. ok
t1001.t .. ok
All tests successful.
Files=2, Tests=2,  0 wallclock secs ( 0.01 usr  0.00 sys +  0.02 cusr  0.00 csys =  0.03 CPU)
Result: PASS
make clean-except-prove-cache
rm -f -r 'trash directory'.* test-results
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   create-stamp debian/debhelper-build-stamp
   dh_prep
   debian/rules override_dh_auto_install
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
dh_auto_configure --buildsystem=meson
	cd obj-x86_64-linux-gnu && DEB_PYTHON_INSTALL_LAYOUT=deb LC_ALL=C.UTF-8 meson setup .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu -Dpython.bytecompile=-1
The Meson build system
Version: 1.4.1
Source dir: /home/mick/Packages/labwc/labwc-menu-generator-0.1.0
Build dir: /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu
Build type: native build
Project name: labwc-menu-generator
Project version: 0.1.0
C compiler for the host machine: cc (gcc 13.2.0 "cc (Debian 13.2.0-25) 13.2.0")
C linker for the host machine: cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1
Run-time dependency glib-2.0 found: YES 2.80.2
Program scdoc found: YES (/usr/bin/scdoc)
Build targets in project: 2

labwc-menu-generator 0.1.0

  User defined options
    buildtype         : plain
    libdir            : lib/x86_64-linux-gnu
    localstatedir     : /var
    prefix            : /usr
    sysconfdir        : /etc
    wrap_mode         : nodownload
    python.bytecompile: -1

Found ninja-1.12.1 at /usr/bin/ninja
meson compile -C obj-x86_64-linux-gnu/
ninja: Entering directory `/home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu'
[1/5] Generating data/labwc-menu-generator.1 with a custom command (wrapped by meson to capture output, to feed input)
[2/5] Compiling C object labwc-menu-generator.p/ignore.c.o
[3/5] Compiling C object labwc-menu-generator.p/main.c.o
[4/5] Compiling C object labwc-menu-generator.p/desktop.c.o
[5/5] Linking target labwc-menu-generator
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu
meson install -C obj-x86_64-linux-gnu/ --destdir=$(pwd)/debian/labwc-menu-generator
ninja: Entering directory `/home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu'
ninja: no work to do.
Installing labwc-menu-generator to /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/debian/labwc-menu-generator/usr/bin
Installing data/labwc-menu-generator.1 to /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/debian/labwc-menu-generator/usr/share/man/man1
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_installdocs
   dh_installchangelogs
   dh_installman
   dh_perl
   dh_link
   dh_strip_nondeterminism
   dh_compress
   dh_fixperms
   dh_missing
   dh_dwz -a
   dh_strip -a
   dh_makeshlibs -a
   dh_shlibdeps -a
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package 'labwc-menu-generator' in '../labwc-menu-generator_0.1.0-1_amd64.deb'.
dpkg-deb: building package 'labwc-menu-generator-dbgsym' in '../labwc-menu-generator-dbgsym_0.1.0-1_amd64.deb'.
 dpkg-genbuildinfo -O../labwc-menu-generator_0.1.0-1_amd64.buildinfo
 dpkg-genchanges -O../labwc-menu-generator_0.1.0-1_amd64.changes
dpkg-genchanges: info: including full source code in upload
 dpkg-source --after-build .
dpkg-source: info: unapplying 000-stringop-truncation.patch
dpkg-buildpackage: info: full upload (original source is included)
Now running lintian labwc-menu-generator_0.1.0-1_amd64.changes ...
Finished running lintian.

The patch seems too simple

  1. I can't reproduce this outside of the "debian way" even with -Wstringop-truncation, patched or original
  2. why is it only need in line line 51? Ok, I understand that llcc is longer than ll and I realise they are both allocated [24] and that the - 1 I've inserted is for \0. Is that a reasonable explanation?
  3. Should I offer a PR or am I being OCD about warnings in the "debian way"?
@Consolatis
Copy link
Member

Good find. I can't say why it doesn't warn about it during a usual compile but it should, it is a legitimate issue:

  The  strncpy()  function is similar, except that at most n bytes of src are copied.  Warning: If
  there is no null byte among the first n bytes of src, the string placed  in  dest  will  not  be
  null-terminated

Maybe this should have a small wrapper for strncpy() that automatically decreases the size by one and ensures a \0 at the end.

@01micko
Copy link
Contributor Author

01micko commented Jun 15, 2024

Maybe this should have a small wrapper for strncpy() that automatically decreases the size by one and ensures a \0 at the end.

Maybe. Probably above my pay grade!

@01micko
Copy link
Contributor Author

01micko commented Jun 15, 2024

strlcpy() but non-standard

snprintf() has advantage of checking return value (int).

@johanmalm
Copy link
Collaborator

johanmalm commented Jun 15, 2024

Let’s just use snprintf()

Better to patch in-tree.

There is strlcpy() but needs a compat layer so too much faff in this situation.

— Edit — sorry typed before I saw above

@01micko
Copy link
Contributor Author

01micko commented Jun 15, 2024

Thanks @johanmalm

I'll test it out the "debian way" and when all is good I'll do up a PR :)

@01micko
Copy link
Contributor Author

01micko commented Jun 15, 2024

Built and tested fine the "debian way"

success log
 dpkg-buildpackage -rfakeroot -us -uc -ui
dpkg-buildpackage: info: source package labwc-menu-generator
dpkg-buildpackage: info: source version 0.1.0-1
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by Mick Mars <[email protected]>
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: applying 000-purge-strncmp.patch
 debian/rules clean
dh clean
   dh_auto_clean
	make -j6 clean
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
rm -f -r 'trash directory'.* test-results
rm -f .prove
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_clean
 dpkg-source -b .
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building labwc-menu-generator using existing ./labwc-menu-generator_0.1.0.orig.tar.gz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: building labwc-menu-generator in labwc-menu-generator_0.1.0-1.debian.tar.xz
dpkg-source: info: building labwc-menu-generator in labwc-menu-generator_0.1.0-1.dsc
 debian/rules binary
dh binary
   dh_update_autotools_config
   dh_autoreconf
   dh_auto_configure
   dh_auto_build
	make -j6 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o main.o main.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o desktop.o desktop.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -Wdate-time -D_FORTIFY_SOURCE=2  -c -o ignore.o ignore.c
c99 -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/mick/Packages/labwc/labwc-menu-generator-0.1.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -Wall -Os -std=c99 -Wextra `pkg-config --cflags glib-2.0` -o labwc-menu-generator main.o desktop.o ignore.o -Wl,-z,relro `pkg-config --libs glib-2.0`
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_auto_test
	make -j6 check
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
rm -f -r test-results
*** prove ***
t1000.t .. ok
t1001.t .. ok
All tests successful.
Files=2, Tests=2,  1 wallclock secs ( 0.01 usr  0.01 sys +  0.01 cusr  0.01 csys =  0.04 CPU)
Result: PASS
make clean-except-prove-cache
rm -f -r 'trash directory'.* test-results
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   create-stamp debian/debhelper-build-stamp
   dh_prep
   debian/rules override_dh_auto_install
make[1]: Entering directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
dh_auto_configure --buildsystem=meson
	cd obj-x86_64-linux-gnu && DEB_PYTHON_INSTALL_LAYOUT=deb LC_ALL=C.UTF-8 meson setup .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu -Dpython.bytecompile=-1
The Meson build system
Version: 1.4.1
Source dir: /home/mick/Packages/labwc/labwc-menu-generator-0.1.0
Build dir: /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu
Build type: native build
Project name: labwc-menu-generator
Project version: 0.1.0
C compiler for the host machine: cc (gcc 13.2.0 "cc (Debian 13.2.0-25) 13.2.0")
C linker for the host machine: cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1
Run-time dependency glib-2.0 found: YES 2.80.2
Program scdoc found: YES (/usr/bin/scdoc)
Build targets in project: 2

labwc-menu-generator 0.1.0

  User defined options
    buildtype         : plain
    libdir            : lib/x86_64-linux-gnu
    localstatedir     : /var
    prefix            : /usr
    sysconfdir        : /etc
    wrap_mode         : nodownload
    python.bytecompile: -1

Found ninja-1.12.1 at /usr/bin/ninja
meson compile -C obj-x86_64-linux-gnu/
ninja: Entering directory `/home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu'
[1/5] Generating data/labwc-menu-generator.1 with a custom command (wrapped by meson to capture output, to feed input)
[2/5] Compiling C object labwc-menu-generator.p/ignore.c.o
[3/5] Compiling C object labwc-menu-generator.p/main.c.o
[4/5] Compiling C object labwc-menu-generator.p/desktop.c.o
[5/5] Linking target labwc-menu-generator
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu
meson install -C obj-x86_64-linux-gnu/ --destdir=$(pwd)/debian/labwc-menu-generator
ninja: Entering directory `/home/mick/Packages/labwc/labwc-menu-generator-0.1.0/obj-x86_64-linux-gnu'
ninja: no work to do.
Installing labwc-menu-generator to /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/debian/labwc-menu-generator/usr/bin
Installing data/labwc-menu-generator.1 to /home/mick/Packages/labwc/labwc-menu-generator-0.1.0/debian/labwc-menu-generator/usr/share/man/man1
make[1]: Leaving directory '/home/mick/Packages/labwc/labwc-menu-generator-0.1.0'
   dh_installdocs
   dh_installchangelogs
   dh_installman
   dh_perl
   dh_link
   dh_strip_nondeterminism
   dh_compress
   dh_fixperms
   dh_missing
   dh_dwz -a
   dh_strip -a
   dh_makeshlibs -a
   dh_shlibdeps -a
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package 'labwc-menu-generator' in '../labwc-menu-generator_0.1.0-1_amd64.deb'.
dpkg-deb: building package 'labwc-menu-generator-dbgsym' in '../labwc-menu-generator-dbgsym_0.1.0-1_amd64.deb'.
 dpkg-genbuildinfo -O../labwc-menu-generator_0.1.0-1_amd64.buildinfo
 dpkg-genchanges -O../labwc-menu-generator_0.1.0-1_amd64.changes
dpkg-genchanges: info: including full source code in upload
 dpkg-source --after-build .
dpkg-source: info: unapplying 000-purge-strncmp.patch
dpkg-buildpackage: info: full upload (original source is included)
Now running lintian labwc-menu-generator_0.1.0-1_amd64.changes ...
Finished running lintian.
000-purge-strncmp.patch
From: Mick Mars <[email protected]>
Description: set purge strncmp patch
--- labwc-menu-generator-0.1.0.orig/desktop.c	2024-06-09 07:55:30.082028828 +1000
+++ labwc-menu-generator-0.1.0/desktop.c	2024-06-15 19:13:44.653107939 +1000
@@ -48,25 +48,43 @@
 	}
 
 	/* ll_CC */
-	strncpy(llcc, p, sizeof(llcc));
+	int ret = snprintf(llcc, sizeof(llcc), "%s", p);
+	if (ret < 0) {
+		return;
+	}
 	p = strrchr(llcc, '.');
 	if (p) {
 		*p = '\0';
 	}
 
 	/* ll */
-	strncpy(ll, llcc, sizeof(ll));
+	ret = snprintf(ll, sizeof(ll), "%s", llcc);
+	if (ret < 0) {
+		return;
+	}
 	p = strrchr(ll, '_');
 	if (p) {
 		*p = '\0';
 	}
 
-	snprintf(name_ll, sizeof(name_ll), "Name[%s]", ll);
-	snprintf(name_llcc, sizeof(name_llcc), "Name[%s]", llcc);
-	snprintf(generic_name_ll, sizeof(generic_name_ll),
+	ret = snprintf(name_ll, sizeof(name_ll), "Name[%s]", ll);
+	if (ret < 0) {
+		return;
+	}
+	ret = snprintf(name_llcc, sizeof(name_llcc), "Name[%s]", llcc);
+	if (ret < 0) {
+		return;
+	}
+	ret = snprintf(generic_name_ll, sizeof(generic_name_ll),
 		"GenericName[%s]", ll);
-	snprintf(generic_name_llcc, sizeof(generic_name_llcc),
+	if (ret < 0) {
+		return;
+	}
+	ret = snprintf(generic_name_llcc, sizeof(generic_name_llcc),
 		"GenericName[%s]", llcc);
+	if (ret < 0) {
+		return;
+	}
 }
 
 char *name_ll_get(void) { return name_ll; }
@@ -303,8 +321,14 @@
 		return;
 	}
 	size_t len = strlen(path);
-	strncpy(fullname, path, sizeof(fullname));
-	strncpy(fullname + len, filename, sizeof(fullname) - len);
+	int ret = snprintf(fullname, sizeof(fullname), "%s", path);
+	if (ret < 0) {
+		return;
+	}
+	ret = snprintf(fullname + len, sizeof(fullname) - len, "%s", filename);
+	if (ret < 0) {
+		return;
+	}
 	FILE *fp = fopen(fullname, "r");
 	if (!fp) {
 		fprintf(stderr, "warn: could not open file %s", filename);

Sanity checked standalone as well, even though the t tests worked.

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

Successfully merging a pull request may close this issue.

3 participants