bug#79194: Segfault with 0 byte symbol

a aa <[email protected]> Thu, 7 Aug 2025 13:35:20 -0400
Newsgroups gmane.lisp.guile.bugs
Message-ID <CAN=a0Hrpycwn66zTHobdN7Thza1JtCQD2AekXLHMYsWZFBNviw@mail.gmail.com>
--0000000000005eaf13063bc9e285
Content-Type: multipart/alternative; boundary="0000000000005eaf11063bc9e283"

--0000000000005eaf11063bc9e283
Content-Type: text/plain; charset="UTF-8"

Hello,

how to reproduce:
cc main.c `pkg-config --libs --cflags guile-3.0` && ./a.out

incorrect behaviour:
The second parameter for scm_from_utf8_symboln should be how many bytes are
pointed to by the pointer however the pointer still gets read if the length
is zero. Being able to handle 0 byte strings is expected since replacing
the call from scm_from_utf8_symboln to scm_from_utf8_stringn will not have
a segfault and the documentation for this function does not mention being
unable to handle 0 byte strings.

version: 3.0.10 (built from source via gentoo ebuild)

config.guess:
x86_64-pc-linux-gnu

config.status:
--prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
--sysconfdir=/etc --localstatedir=/var/lib --datarootdir=/usr/share
--disable-dependency-tracking --disable-silent-rules --disable-static
--docdir=/usr/share/doc/guile-3.0.10-r103
--htmldir=/usr/share/doc/guile-3.0.10-r103/html --with-sysroot=/
--libdir=/usr/lib64 --program-suffix=-3.0
--infodir=/usr/share/guile-data/3.0/info
--with-pkgconfigdir=/usr/share/guile-data/3.0/pkgconfig
--disable-error-on-warning --disable-rpath --disable-lto --enable-posix
--without-libgmp-prefix --without-libiconv-prefix --without-libintl-prefix
--without-libreadline-prefix --without-libunistring-prefix
--disable-guile-debug --disable-debug-malloc --enable-deprecated
--enable-jit --enable-networking --disable-nls --enable-regex
--with-threads build_alias=x86_64-pc-linux-gnu
host_alias=x86_64-pc-linux-gnu CC=gcc 'CFLAGS=-O2 -march=native -pipe
-std=gnu17' LDFLAGS=-fuse-ld=mold
PKG_CONFIG_PATH=/usr/share/guile-data/3.0/pkgconfig

--0000000000005eaf11063bc9e283
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hello,</div><div><br></div><div>how to reproduce:</di=
v><div>cc main.c `pkg-config --libs --cflags guile-3.0` &amp;&amp; ./a.out<=
/div><div><br></div><div>incorrect behaviour:</div><div>The second paramete=
r for scm_from_utf8_symboln should be how many bytes are pointed to by the =
pointer however the pointer still gets read if the length is zero. Being ab=
le to handle 0 byte strings is expected since replacing the call from scm_f=
rom_utf8_symboln to scm_from_utf8_stringn will not have a segfault and the =
documentation for this function does not mention being unable to handle 0 b=
yte strings.</div><div><br></div><div>version: 3.0.10 (built from source vi=
a gentoo ebuild)</div><div><br></div><div>config.guess:</div><div>x86_64-pc=
-linux-gnu</div><div><br></div><div>config.status:<br>--prefix=3D/usr --bui=
ld=3Dx86_64-pc-linux-gnu=20
--host=3Dx86_64-pc-linux-gnu --mandir=3D/usr/share/man=20
--infodir=3D/usr/share/info --datadir=3D/usr/share --sysconfdir=3D/etc=20
--localstatedir=3D/var/lib --datarootdir=3D/usr/share=20
--disable-dependency-tracking --disable-silent-rules --disable-static=20
--docdir=3D/usr/share/doc/guile-3.0.10-r103 --htmldir=3D/usr/share/doc/guil=
e-3.0.10-r103/html --with-sysroot=3D/ --libdir=3D/usr/lib64 --program-suffi=
x=3D-3.0 --infodir=3D/usr/share/guile-data/3.0/info --with-pkgconfigdir=3D/=
usr/share/guile-data/3.0/pkgconfig
 --disable-error-on-warning --disable-rpath --disable-lto --enable-posix
 --without-libgmp-prefix --without-libiconv-prefix=20
--without-libintl-prefix --without-libreadline-prefix=20
--without-libunistring-prefix --disable-guile-debug=20
--disable-debug-malloc --enable-deprecated --enable-jit=20
--enable-networking --disable-nls --enable-regex --with-threads=20
build_alias=3Dx86_64-pc-linux-gnu host_alias=3Dx86_64-pc-linux-gnu=20
CC=3Dgcc &#39;CFLAGS=3D-O2 -march=3Dnative -pipe -std=3Dgnu17&#39; LDFLAGS=
=3D-fuse-ld=3Dmold
 PKG_CONFIG_PATH=3D/usr/share/guile-data/3.0/pkgconfig=C2=A0<br></div><div>=
<br></div></div>

--0000000000005eaf11063bc9e283--

--0000000000005eaf13063bc9e285
Content-Type: text/plain; charset="US-ASCII"; name="main.c"
Content-Disposition: attachment; filename="main.c"
Content-Transfer-Encoding: base64
Content-ID: <f_me1o799f0>
X-Attachment-Id: f_me1o799f0

I2luY2x1ZGUgPGxpYmd1aWxlLmg+Cgp2b2lkKiBpbm5lcl9tYWluKHZvaWQqKSB7CiAgU0NNIHN5
bSA9IHNjbV9mcm9tX3V0Zjhfc3ltYm9sbihOVUxMLCAwKTsKCiAgcmV0dXJuIDA7Cn0KCmludCBt
YWluKHZvaWQpIHsKICBzY21fd2l0aF9ndWlsZShpbm5lcl9tYWluLCAwKTsKCiAgcmV0dXJuIDA7
Cn0K
--0000000000005eaf13063bc9e285--