Commit Graph

2 Commits

Author SHA1 Message Date
Matteo Croce
8804116fd0 fix obscure invalid memory access in zipinfo
zipinfo prints random garbage (and sometime crashes) when showing the usage:
run 1:
	miscellaneous options:
	  -h  print header line       -t  print totals for listed files or for all
	  -z  print zipfile comment   -T? print file times in sortable decimal format
	 ?-C  be case-insensitive  4l?????```??`????????????????????????????????

run 2:
	miscellaneous options:
	  -h  print header line       -t  print totals for listed files or for all
	  -z  print zipfile comment  `-T? print file times in sortable decimal format
	 ?-C? be case-insensitive   (null)  -x  exclude filenames that follow from listing

run 3:
	miscellaneous options:
	  -h  print header line       -t  print totals for listed files or for all
	  -z  print zipfile comment  ?-T? print file times in sortable decimal format
	 -Cv be case-insensitive   20 April 2009  -x  exclude filenames that follow from listing

run 4: segmentation fault

This happens because four '%c' modifiers are passed to sprintf, without
any corresponding argument.
This obviously generates a long list of compiler warnings, which are
ignored:

	In file included from unzip.h:720,
	                 from unzip.c:68:
	unzip.c: In function ‘usage’:
	unzpriv.h:1009:45: warning: format ‘%c’ expects argument of type ‘int’, but argument 3 has type ‘char *’ [-Wformat=]
	 1009 | #    define LoadFarString(x)        (char *)(x)
	      |                                             ^
	unzpriv.h:2728:61: note: in definition of macro ‘Info’
	 2728 |        (*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag))
	      |                                                             ^~~~~~~~
	unzip.c:2133:43: note: in expansion of macro ‘LoadFarString’
	 2133 |         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
	      |                                           ^~~~~~~~~~~~~
	unzpriv.h:1009:45: warning: format ‘%c’ expects a matching ‘int’ argument [-Wformat=]
	 1009 | #    define LoadFarString(x)        (char *)(x)
	      |                                             ^
	unzpriv.h:2728:61: note: in definition of macro ‘Info’
	 2728 |        (*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag))
	      |                                                             ^~~~~~~~
	unzip.c:2133:43: note: in expansion of macro ‘LoadFarString’
	 2133 |         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
	      |                                           ^~~~~~~~~~~~~
	unzpriv.h:1009:45: warning: format ‘%c’ expects a matching ‘int’ argument [-Wformat=]
	 1009 | #    define LoadFarString(x)        (char *)(x)
	      |                                             ^
	unzpriv.h:2728:61: note: in definition of macro ‘Info’
	 2728 |        (*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag))
	      |                                                             ^~~~~~~~
	unzip.c:2133:43: note: in expansion of macro ‘LoadFarString’
	 2133 |         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
	      |                                           ^~~~~~~~~~~~~
	unzpriv.h:1009:45: warning: format ‘%c’ expects a matching ‘int’ argument [-Wformat=]
	 1009 | #    define LoadFarString(x)        (char *)(x)
	      |                                             ^
	unzpriv.h:2728:61: note: in definition of macro ‘Info’
	 2728 |        (*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag))
	      |                                                             ^~~~~~~~
	unzip.c:2133:43: note: in expansion of macro ‘LoadFarString’
	 2133 |         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
	      |                                           ^~~~~~~~~~~~~
	unzpriv.h:1009:45: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
	 1009 | #    define LoadFarString(x)        (char *)(x)
	      |                                             ^
	unzpriv.h:2728:61: note: in definition of macro ‘Info’
	 2728 |        (*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag))
	      |                                                             ^~~~~~~~
	unzip.c:2133:43: note: in expansion of macro ‘LoadFarString’
	 2133 |         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
	      |                                           ^~~~~~~~~~~~~

Fix this by removing the '%c' modifiers.
Resolves: RHEL-60054

Signed-off-by: Matteo Croce <teknoraver@meta.com>
2024-09-25 17:13:37 +02:00
Troy Dawson
812100f3e3 RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/unzip#7ca60a3df8e6a2b281937307d418993e08cfca3f
2020-10-15 13:15:25 -07:00