Menu

#79 zip: Charset conversion fails when zip is built with _FORTIFY_SOURCE

v1.0 (example)
open
nobody
None
5
2025-04-22
2025-04-22
No

Hello. This is Debian Bug #1077054 and this is the full URL for the bug:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1077054

Follows a summary of the bug.

Adam Sampson writes:

If zip 3.0-14 is built with _FORTIFY_SOURCE=3 (GCC 14.1, glibc 2.40),
this can happen when compressing a file with non-ASCII characters in its
UTF-8 name:

$ echo -n "There’s a Baby in the House.flac" | od -c
0000000   T   h   e   r   e 342 200 231   s       a       B   a   b   y
0000020       i   n       t   h   e       H   o   u   s   e   .   f   l
0000040   a   c
$ zip /tmp/t.zip "There’s a Baby in the House.flac"
*** buffer overflow detected ***: terminated

The problem is in local_to_wide_string, where mbstowcs is being run with
the UTF-8 source length rather than the widechar destination length --
this correctly trips a fortify error because GCC 14 can infer the actual
size of the destination.

I've attached a patch.
1 Attachments

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.