• Bug#1060407: gtkwave update for {bookworm,bullseye,buster}-security (3/

    From Adrian Bunk@21:1/5 to All on Fri Mar 29 00:10:01 2024
    [continued from previous message]

    ++ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
    ++ for more details.
    ++
    ++ You should have received a copy of the GNU General Public License
    ++ along with GCC; see the file COPYING. If not, write to the Free
    ++ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    ++ 02111-1307, USA.
    ++*/
    ++
    ++
    ++#ifndef _GHWLIB_H_
    ++#define _GHWLIB_H_
    ++
    ++#include <stdio.h>
    ++#include <stdlib.h>
    ++
    ++#ifdef HAVE_CONFIG_H
    ++#include "config.h"
    ++#endif
    ++
    ++/* The ghwlib uses the standard c99 int32_t and int64_t. They are declared ++ in stdint.h. Header inttypes.h includes stdint.h and provides macro for ++ printf and co specifiers. Use it if known to be available. */
    ++
    ++#if defined(__cplusplus) \
    ++ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
    ++ || defined(HAVE_INTTYPES_H)
    ++/* Use C99 standard header. */
    ++# include <inttypes.h>
    ++# define GHWPRI64 "%"PRId64
    ++# define GHWPRI32 "%"PRId32
    ++#else
    ++# include <stdint.h>
    ++# define GHWPRI64 "%lld"
    ++# define GHWPRI32 "%d"
    ++#endif
    ++
    ++enum ghdl_rtik {
    ++ ghdl_rtik_top, /* 0 */
    ++ ghdl_rtik_library,
    ++ ghdl_rtik_package,
    ++ ghdl_rtik_package_body,
    ++ ghdl_rtik_entity,
    ++ ghdl_rtik_architecture, /* 5 */
    ++ ghdl_rtik_process,
    ++ ghdl_rtik_block,
    ++ ghdl_rtik_if_generate,
    ++ ghdl_rtik_for_generate,
    ++ ghdl_rtik_instance,
    ++ ghdl_rtik_constant,
    ++ ghdl_rtik_iterator,
    ++ ghdl_rtik_variable,
    ++ ghdl_rtik_signal,
    ++ ghdl_rtik_file,
    ++ ghdl_rtik_port,
    ++ ghdl_rtik_generic,
    ++ ghdl_rtik_alias,
    ++ ghdl_rtik_guard,
    ++ ghdl_rtik_component,
    ++ ghdl_rtik_attribute,
    ++ ghdl_rtik_type_b2, /* 22 */
    ++ ghdl_rtik_type_e8,
    ++ ghdl_rtik_type_e32,
    ++ ghdl_rtik_type_i32, /* 25 */
    ++ ghdl_rtik_type_i64,
    ++ ghdl_rtik_type_f64,
    ++ ghdl_rtik_type_p32,
    ++ ghdl_rtik_type_p64,
    ++ ghdl_rtik_type_access, /* 30 */
    ++ ghdl_rtik_type_array,
    ++ ghdl_rtik_type_record,
    ++ ghdl_rtik_type_file,
    ++ ghdl_rtik_subtype_scalar,
    ++ ghdl_rtik_subtype_array, /* 35 */
    ++ ghdl_rtik_subtype_array_ptr, /* Obsolete. */
    ++ ghdl_rtik_subtype_unconstrained_array, /* Obsolete. */
    ++ ghdl_rtik_subtype_record,
    ++ ghdl_rtik_subtype_access,
    ++ ghdl_rtik_type_protected,
    ++ ghdl_rtik_element,
    ++ ghdl_rtik_unit,
    ++ ghdl_rtik_attribute_transaction,
    ++ ghdl_rtik_attribute_quiet,
    ++ ghdl_rtik_attribute_stable,
    ++ ghdl_rtik_error
    ++};
    ++
    ++/* Well-known types. */
    ++enum ghw_wkt_type {
    ++ ghw_wkt_unknown,
    ++ ghw_wkt_boolean,
    ++ ghw_wkt_bit,
    ++ ghw_wkt_std_ulogic
    ++};
    ++
    ++struct ghw_range_b2
    ++{
    ++ enum ghdl_rtik kind : 8;
    ++ int dir : 8; /* 0: to, !0: downto. */
    ++ unsigned char left;
    ++ unsigned char right;
    ++};
    ++
    ++struct ghw_range_e8
    ++{
    ++ enum ghdl_rtik kind : 8;
    ++ int dir : 8; /* 0: to, !0: downto. */
    ++ unsigned char left;
    ++ unsigned char right;
    ++};
    ++
    ++struct ghw_range_i32
    ++{
    ++ enum ghdl_rtik kind : 8;
    ++ int dir : 8; /* 0: to, !0: downto. */
    ++ int32_t left;
    ++ int32_t right;
    ++};
    ++
    ++struct ghw_range_i64
    ++{
    ++ enum ghdl_rtik kind : 8;
    ++ int dir : 8;
    ++ int64_t left;
    ++ int64_t right;
    ++};
    ++
    ++struct ghw_range_f64
    ++{
    ++ enum ghdl_rtik kind : 8;
    ++ int dir : 8;
    ++ double left;
    ++ double right;
    ++};
    ++
    ++union ghw_range
    ++{
    ++ enum ghdl_rtik kind : 8;
    ++ struct ghw_range_b2 b2;
    ++ struct ghw_range_e8 e8;
    ++ struct ghw_range_i32 i32;
    ++ struct ghw_range_i64 i64;
    ++ struct ghw_range_f64 f64;
    ++};
    ++
    ++/* Note: the first two fields must be kind and name. */
    ++union ghw_type;
    ++
    ++struct ghw_type_common
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++};
    ++
    ++struct ghw_type_enum
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++
    ++ enum ghw_wkt_type wkt;
    ++ unsigned int nbr;
    ++ const char **lits;
    ++};
    ++
    ++struct ghw_type_scalar
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++};
    ++
    ++struct ghw_unit
    ++{
    ++ const char *name;
    ++ int64_t val;
    ++};
    ++
    ++struct ghw_type_physical
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++ uint32_t nbr_units;
    ++ struct ghw_unit *units;
    ++};
    ++
    ++struct ghw_type_array
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++
    ++ unsigned int nbr_dim;
    ++ union ghw_type *el;
    ++ union ghw_type **dims;
    ++};
    ++
    ++struct ghw_subtype_array
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++
    ++ struct ghw_type_array *base;
    ++ int nbr_scalars;
    ++ union ghw_range **rngs;
    ++};
    ++
    ++struct ghw_subtype_scalar
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++
    ++ union ghw_type *base;
    ++ union ghw_range *rng;
    ++};
    ++
    ++struct ghw_record_element
    ++{
    ++ const char *name;
    ++ union ghw_type *type;
    ++};
    ++
    ++struct ghw_type_record
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++
    ++ unsigned int nbr_fields;
    ++ int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */ ++ struct ghw_record_element *els;
    ++};
    ++
    ++struct ghw_subtype_record
    ++{
    ++ enum ghdl_rtik kind;
    ++ const char *name;
    ++
    ++ struct ghw_type_record *base;
    ++ int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */ ++ struct ghw_record_element *els;
    ++};
    ++
    ++union ghw_type
    ++{
    ++ enum ghdl_rtik kind;
    ++ struct ghw_type_common common;
    ++ struct ghw_type_enum en;
    ++ struct ghw_type_scalar sc;
    ++ struct ghw_type_physical ph;
    ++ struct ghw_subtype_scalar ss;
    ++ struct ghw_subtype_array sa;
    ++ struct ghw_subtype_record sr;
    ++ struct ghw_type_array ar;
    ++ struct ghw_type_record rec;
    ++};
    ++
    ++union ghw_val
    ++{
    ++ unsigned char b2;
    ++ unsigned char e8;
    ++ int32_t i32;
    ++ int64_t i64;
    ++ double f64;
    ++};
    ++
    ++/* A non-composite signal. */
    ++struct ghw_sig
    ++{
    ++ union ghw_type *type;
    ++ union ghw_val *val;
    ++};
    ++
    ++enum ghw_hie_kind {
    ++ ghw_hie_eoh = 0,
    ++ ghw_hie_design = 1,
    ++ ghw_hie_block = 3,
    ++ ghw_hie_generate_if = 4,
    ++ ghw_hie_generate_for = 5,
    ++ ghw_hie_instance = 6,
    ++ ghw_hie_package = 7,
    ++ ghw_hie_process = 13,
    ++ ghw_hie_generic = 14,
    ++ ghw_hie_eos = 15,
    ++ ghw_hie_signal = 16,
    ++ ghw_hie_port_in = 17,
    ++ ghw_hie_port_out = 18,
    ++ ghw_hie_port_inout = 19,
    ++ ghw_hie_port_buffer = 20,
    ++ ghw_hie_port_linkage = 21
    ++};
    ++
    ++#define GHW_NO_SIG 0
    ++
    ++struct ghw_hie
    ++{
    ++ enum ghw_hie_kind kind;
    ++ struct ghw_hie *parent;
    ++ const char *name;
    ++ struct ghw_hie *brother;
    ++ union
    ++ {
    ++ struct
    ++ {
    ++ struct ghw_hie *child;
    ++ union ghw_type *iter_type;
    ++ union ghw_val *iter_value;
    ++ } blk;
    ++ struct
    ++ {
    ++ union ghw_type *type;
    ++ /* Array of signal elements.
    ++ Last element is GHW_NO_SIG (0). */
    ++ unsigned int *sigs;
    ++ } sig;
    ++ } u;
    ++};
    ++
    ++struct ghw_handler
    ++{
    ++ FILE *stream;
    ++ /* True if STREAM was popen, else was fopen. */
    ++ unsigned char stream_ispipe;
    ++ /* True if words are big-endian. */
    ++ unsigned char word_be;
    ++ unsigned char word_len;
    ++ unsigned char off_len;
    ++ /* Minor version. */
    ++ int version;
    ++
    ++ /* Set by user. */
    ++ int flag_verbose;
    ++
    ++ /* String table. */
    ++ /* Number of strings. */
    ++ unsigned nbr_str;
    ++ /* Size of the strings (without nul). */
    ++ unsigned str_size;
    ++ /* String table. */
    ++ char **str_table;
    ++ /* Array containing strings. */
    ++ char *str_content;
    ++
    ++ /* Type table. */
    ++ unsigned nbr_types;
    ++ union ghw_type **types;
    ++
    ++ /* Non-composite (or basic) signals. */
    ++ unsigned nbr_sigs;
    ++ char *skip_sigs;
    ++ int flag_full_names;
    ++ struct ghw_sig *sigs;
    ++
    ++ /* Hierarchy. */
    ++ struct ghw_hie *hie;
    ++
    ++ /* Time of the next cycle. */
    ++ int64_t snap_time;
    ++};
    ++
    ++/* Open a GHW file with H.
    ++ Return < 0 in case of error. */
    ++int ghw_open (struct ghw_handler *h, const char *filename);
    ++
    ++/* Return base type of T. */
    ++union ghw_type *ghw_get_base_type (union ghw_type *t);
    ++
    ++/* Return length of RNG. */
    ++int ghw_get_range_length (union ghw_range *rng);
    ++
    ++/* Put the ASCII representation of VAL into BUF, whose size if LEN.
    ++ A NUL is always written to BUF. */
    ++void ghw_get_value (char *buf, int len,
    ++ union ghw_val *val, union ghw_type *type);
    ++
    ++const char *ghw_get_hie_name (struct ghw_hie *h);
    ++
    ++void ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top);
    ++
    ++int ghw_read_base (struct ghw_handler *h);
    ++
    ++void ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep);
    ++
    ++void ghw_disp_values (struct ghw_handler *h);
    ++
    ++int ghw_read_cycle_start (struct ghw_handler *h);
    ++
    ++int ghw_read_cycle_cont (struct ghw_handler *h, int *list);
    ++
    ++int ghw_read_cycle_next (struct ghw_handler *h);
    ++
    ++int ghw_read_cycle_end (struct ghw_handler *h);
    ++
    ++enum ghw_sm_type {
    ++ /* At init;
    ++ Read section name. */
    ++ ghw_sm_init = 0,
    ++ ghw_sm_sect = 1,
    ++ ghw_sm_cycle = 2
    ++};
    ++
    ++enum ghw_res {
    ++ ghw_res_error = -1,
    ++ ghw_res_eof = -2,
    ++ ghw_res_ok = 0,
    ++ ghw_res_snapshot = 1,
    ++ ghw_res_cycle = 2,
    ++ ghw_res_other = 3
    ++};
    ++
    ++int ghw_read_sm (struct ghw_handler *h, enum ghw_sm_type *sm);
    ++
    ++int ghw_read_dump (struct ghw_handler *h);
    ++
    ++struct ghw_section {
    ++ const char name[4];
    ++ int (*handler)(struct ghw_handler *h);
    ++};
    ++
    ++extern struct ghw_section ghw_sections[];
    ++
    ++int ghw_read_section (struct ghw_handler *h);
    ++
    ++void ghw_close (struct ghw_handler *h);
    ++
    ++const char *ghw_get_dir (int is_downto);
    ++
    ++void ghw_disp_subtype_indication (struct ghw_handler *h, union ghw_type *t); ++
    ++/* Note: TYPE must be a base type (used only to display literals). */
    ++void ghw_disp_range (union ghw_type *type, union ghw_range *rng);
    ++
    ++void ghw_disp_type (struct ghw_handler *h, union ghw_type *t);
    ++
    ++void ghw_disp_types (struct ghw_handler *h);
    ++
    ++enum ghw_res ghw_read_sm_hdr (struct ghw_handler *h, int *list);
    ++
    ++#endif /* _GHWLIB_H_ */
    +--- gtkwave-3.3.104+really3.3.118.orig/src/helpers/Makefile.am
    ++++ gtkwave-3.3.104+really3.3.118/src/helpers/Makefile.am
    +@@ -8,7 +8,7 @@ LIBLZMA_LDADD = $(LIBXZ_LDADD)
    +
    + AM_CFLAGS= -I$(srcdir)/.. -I$(srcdir)/../.. $(LIBZ_CFLAGS) $(LIBBZ2_CFLAGS) $(LIBLZMA_CFLAGS) $(LIBJUDY_CFLAGS) $(EXTLOAD_CFLAGS) $(RPC_CFLAGS) -I$(srcdir)/fst -I$(srcdir)/../../contrib/rtlbrowse
    +
    +-bin_PROGRAMS= evcd2vcd fst2vcd vcd2fst fstminer lxt2miner lxt2vcd \ ++bin_PROGRAMS= evcd2vcd fst2vcd vcd2fst fstminer ghwdump lxt2miner lxt2vcd \
    + shmidcat vcd2lxt vcd2lxt2 vcd2vzt \
    + vzt2vcd vztminer
    +
    +@@ -42,4 +42,6 @@ vztminer_LDADD= $(LIBZ_LDADD) $(LIBBZ2_L
    + lxt2miner_SOURCES= lxt2miner.c lxt2_read.c lxt2_read.h
    + lxt2miner_LDADD= $(LIBZ_LDADD)
    +
    ++ghwdump_SOURCES= ghwdump.c $(srcdir)/../ghwlib.c
    ++
    + evcd2vcd_SOURCES= evcd2vcd.c $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
    +--- /dev/null
    ++++ gtkwave-3.3.104+really3.3.118/src/helpers/ghwdump.c
    +@@ -0,0 +1,203 @@
    ++/* Display a GHDL Wavefile for debugging.
    ++ Copyright (C) 2005-2008 Tristan Gingold
    ++
    ++ GHDL is free software; you can redistribute it and/or modify it under
    ++ the terms of the GNU General Public License as published by the Free
    ++ Software Foundation; either version 2, or (at your option) any later
    ++ version.
    ++
    ++ GHDL is distributed in the hope that it will be useful, but WITHOUT ANY ++ WARRANTY; without even the implied warranty of MERCHANTABILITY or
    ++ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
    ++ for more details.
    ++
    ++ You should have received a copy of the GNU General Public License
    ++ along with GCC; see the file COPYING. If not, write to the Free
    ++ Software Foundation, 51 Franklin Street - Suite 500, Boston, MA
    ++ 02110-1335, USA.
    ++*/
    ++
    ++#include <config.h>
    ++#include <stdio.h>
    ++#if HAVE_STDINT_H
    ++#include <stdint.h>
    ++#endif
    ++#include <string.h>
    ++#include <stdlib.h>
    ++#include <unistd.h>
    ++
    ++#include "ghwlib.h"
    ++
    ++#include "wave_locale.h"
    ++
    ++static const char *progname;
    ++void
    ++usage (void)
    ++{
    ++ printf ("usage: %s [OPTIONS] FILEs...\n", progname);
    ++ printf ("Options are:\n"
    ++ " -t display types\n"
    ++ " -h display hierarchy\n"
    ++ " -T display time\n"
    ++ " -s display signals (and time)\n"
    ++ " -l display list of sections\n"
    ++ " -v verbose\n");
    ++}
    ++
    ++int
    ++main (int argc, char **argv)
    ++{
    ++ int i;
    ++ int flag_disp_types;
    ++ int flag_disp_hierarchy;
    ++ int flag_disp_time;
    ++ int flag_disp_signals;
    ++ int flag_list;
    ++ int flag_verbose;
    ++ int eof;
    ++ enum ghw_sm_type sm;
    ++
    ++ progname = argv[0];
    ++ flag_disp_types = 0;
    ++ flag_disp_hierarchy = 0;
    ++ flag_disp_time = 0;
    ++ flag_disp_signals = 0;
    ++ flag_list = 0;
    ++ flag_verbose = 0;
    ++
    ++ WAVE_LOCALE_FIX
    ++
    ++ while (1)
    ++ {
    ++ int c;
    ++
    ++ c = getopt (argc, argv, "thTslv");
    ++ if (c == -1)
    ++ break;
    ++ switch (c)
    ++ {
    ++ case 't':
    ++ flag_disp_types = 1;
    ++ break;
    ++ case 'h':
    ++ flag_disp_hierarchy = 1;
    ++ break;
    ++ case 'T':
    ++ flag_disp_time = 1;
    ++ break;
    ++ case 's':
    ++ flag_disp_signals = 1;
    ++ flag_disp_time = 1;
    ++ break;
    ++ case 'l':
    ++ flag_list = 1;
    ++ break;
    ++ case 'v':
    ++ flag_verbose++;
    ++ break;
    ++ default:
    ++ usage ();
    ++ exit (2);
    ++ }
    ++ }
    ++
    ++ if (optind >= argc)
    ++ {
    ++ usage ();
    ++ return 1;
    ++ }
    ++
    ++ for (i = optind; i < argc; i++)
    ++ {
    ++ struct ghw_handler h;
    ++ struct ghw_handler *hp = &h;
    ++
    ++ hp->flag_verbose = flag_verbose;
    ++
    ++ if (ghw_open (hp, argv[i]) != 0)
    ++ {
    ++ fprintf (stderr, "cannot open ghw file %s\n", argv[i]);
    ++ return 1;
    ++ }
    ++ if (flag_list)
    ++ {
    ++ while (1)
    ++ {
    ++ int section;
    ++
    ++ section = ghw_read_section (hp);
    ++ if (section == -2)
    ++ {
    ++ printf ("eof of file\n");
    ++ break;
    ++ }
    ++ else if (section < 0)
    ++ {
    ++ printf ("Error in file\n");
    ++ break;
    ++ }
    ++ else if (section == 0)
    ++ {
    ++ printf ("Unknown section\n");
    ++ break;
    ++ }
    ++ printf ("Section %s\n", ghw_sections[section].name);
    ++ if ((*ghw_sections[section].handler)(hp) < 0)
    ++ break;
    ++ }
    ++ }
    ++ else
    ++ {
    ++ if (ghw_read_base (hp) < 0)
    ++ {
    ++ fprintf (stderr, "cannot read ghw file\n");
    ++ return 2;
    ++ }
    ++ if (0)
    ++ {
    ++ unsigned ix;
    ++ printf ("String table:\n");
    ++
    ++ for (ix = 1; ix < hp->nbr_str; ix++)
    ++ printf (" %s\n", hp->str_table[ix]);
    ++ }
    ++ if (flag_disp_types)
    ++ ghw_disp_types (hp);
    ++ if (flag_disp_hierarchy)
    ++ ghw_disp_hie (hp, hp->hie);
    ++
    ++#if 1
    ++ sm = ghw_sm_init;
    ++ eof = 0;
    ++ while (!eof)
    ++ {
    ++ switch (ghw_read_sm (hp, &sm))
    ++ {
    ++ case ghw_res_snapshot:
    ++ case ghw_res_cycle:
    ++ if (flag_disp_time)
    ++ printf ("Time is "GHWPRI64" fs\n", hp->snap_time);
    ++ if (flag_disp_signals)
    ++ ghw_disp_values (hp);
    ++ break;
    ++ case ghw_res_eof:
    ++ eof = 1;
    ++ break;
    ++ default:
    ++ abort ();
    ++ }
    ++ }
    ++
    ++#else
    ++ if (ghw_read_dump (hp) < 0)
    ++ {
    ++ fprintf (stderr, "error in ghw dump\n");
    ++ return 3;
    ++ }
    ++#endif
    ++ }
    ++ ghw_close (&h);
    ++ }
    ++ return 0;
    ++}
    ++
    diff -Nru gtkwave-3.3.104/debian/patches/series gtkwave-3.3.104+really3.3.118/debian/patches/series
    --- gtkwave-3.3.104/debian/patches/series 2020-05-26 06:38:15.000000000 +0300
    +++ gtkwave-3.3.104+really3.3.118/debian/patches/series 2024-03-28 09:23:23.000000000 +0200
    @@ -1,2 +1,3 @@
    0001-Add-F-to-exec-key-in-desktop-file.patch
    gcc10-extern.patch
    +readd-ghwdump.patch

    diff -Nru gtkwave-3.3.98/debian/changelog gtkwave-3.3.98+really3.3.118/debian/changelog
    --- gtkwave-3.3.98/debian/changelog 2019-01-14 06:17:28.000000000 +0200
    +++ gtkwave-3.3.98+really3.3.118/debian/changelog 2024-03-28 23:03:07.000000000 +0200
    @@ -1,3 +1,34 @@
    +gtkwave (3.3.98+really3.3.118-0+deb10u1) buster-security; urgency=medium
    +
    + * Non-maintainer upload by the LTS team.
    + * New upstream release.
    + - Fixes multiple vulnerabilities:
    + CVE-2023-32650, CVE-2023-34087, CVE-2023-34436, CVE-2023-35004,
    + CVE-2023-35057, CVE-2023-35128, CVE-2023-35702, CVE-2023-35703,
    + CVE-2023-35704, CVE-2023-35955, CVE-2023-35956, CVE-2023-35957,
    + CVE-2023-35958, CVE-2023-35959, CVE-2023-35960, CVE-2023-35961