NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: toolchain/59549: gdb is not ctype(3) safe



The following reply was made to PR toolchain/59549; it has been noted by GNATS.

From: Christos Zoulas <christos%zoulas.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: toolchain-manager%netbsd.org@localhost,
 gnats-admin%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost,
 Thomas Klausner <wiz%NetBSD.org@localhost>
Subject: Re: toolchain/59549: gdb is not ctype(3) safe
Date: Fri, 25 Jul 2025 08:46:01 -0400

 --Apple-Mail=_2894989C-6E5A-4568-A409-088E55B38E25
 Content-Type: multipart/mixed;
 	boundary="Apple-Mail=_52E1FB37-8163-4E28-B245-A16157BF10ED"
 
 
 --Apple-Mail=_52E1FB37-8163-4E28-B245-A16157BF10ED
 Content-Disposition: attachment;
 	filename=gdb.patch
 Content-Type: application/octet-stream;
 	name=gdb.patch;
 	x-unix-mode=0644
 Content-Transfer-Encoding: 7bit
 
 Index: dist/gdb/ada-lang.c
 ===================================================================
 RCS file: /cvsroot/src/external/gpl3/gdb/dist/gdb/ada-lang.c,v
 retrieving revision 1.9
 diff -u -p -u -r1.9 ada-lang.c
 --- dist/gdb/ada-lang.c	12 Aug 2024 22:09:29 -0000	1.9
 +++ dist/gdb/ada-lang.c	25 Jul 2025 12:44:27 -0000
 @@ -867,7 +867,7 @@ is_compiler_suffix (const char *str)
  {
    gdb_assert (*str == '[');
    ++str;
 -  while (*str != '\0' && isalpha (*str))
 +  while (*str != '\0' && isalpha ((unsigned char)*str))
      ++str;
    /* We accept a missing "]" in order to support completion.  */
    return *str == '\0' || (str[0] == ']' && str[1] == '\0');
 @@ -1159,7 +1159,7 @@ ada_encode (const char *decoded, bool fo
  static int
  is_lower_alphanum (const char c)
  {
 -  return (isdigit (c) || (isalpha (c) && islower (c)));
 +  return (isdigit ((unsigned char)c) || (isalpha ((unsigned char)c) && islower ((unsigned char)c)));
  }
  
  /* ENCODED is the linkage name of a symbol and LEN contains its length.
 @@ -1177,11 +1177,11 @@ is_lower_alphanum (const char c)
  static void
  ada_remove_trailing_digits (const char *encoded, int *len)
  {
 -  if (*len > 1 && isdigit (encoded[*len - 1]))
 +  if (*len > 1 && isdigit ((unsigned char)encoded[*len - 1]))
      {
        int i = *len - 2;
  
 -      while (i > 0 && isdigit (encoded[i]))
 +      while (i > 0 && isdigit ((unsigned char)encoded[i]))
  	i--;
        if (i >= 0 && encoded[i] == '.')
  	*len = i;
 @@ -1212,7 +1212,7 @@ ada_remove_po_subprogram_suffix (const c
  
    if (*len > 1
        && encoded[*len - 1] == 'N'
 -      && (isdigit (encoded[*len - 2]) || islower (encoded[*len - 2])))
 +      && (isdigit ((unsigned char)encoded[*len - 2]) || islower ((unsigned char)encoded[*len - 2])))
      *len = *len - 1;
  }
  
 @@ -1224,7 +1224,7 @@ static int
  remove_compiler_suffix (const char *encoded, int *len)
  {
    int offset = *len - 1;
 -  while (offset > 0 && isalpha (encoded[offset]))
 +  while (offset > 0 && isalpha ((unsigned char)encoded[offset]))
      --offset;
    if (offset > 0 && encoded[offset] == '.')
      {
 @@ -1244,7 +1244,7 @@ convert_hex (const char *str, int n, uin
  
    for (int i = 0; i < n; ++i)
      {
 -      if (!isxdigit (str[i]))
 +      if (!isxdigit ((unsigned char)str[i]))
  	return false;
        result <<= 4;
        result |= fromhex (str[i]);
 @@ -1376,11 +1376,11 @@ ada_decode (const char *encoded, bool wr
  
    /* Remove trailing __{digit}+ or trailing ${digit}+.  */
  
 -  if (len0 > 1 && isdigit (encoded[len0 - 1]))
 +  if (len0 > 1 && isdigit ((unsigned char)encoded[len0 - 1]))
      {
        i = len0 - 2;
 -      while ((i >= 0 && isdigit (encoded[i]))
 -	     || (i >= 1 && encoded[i] == '_' && isdigit (encoded[i - 1])))
 +      while ((i >= 0 && isdigit ((unsigned char)encoded[i]))
 +	     || (i >= 1 && encoded[i] == '_' && isdigit ((unsigned char)encoded[i - 1])))
  	i -= 1;
        if (i > 1 && encoded[i] == '_' && encoded[i - 1] == '_')
  	len0 = i - 1;
 @@ -1391,7 +1391,7 @@ ada_decode (const char *encoded, bool wr
    /* The first few characters that are not alphabetic are not part
       of any encoding we use, so we can copy them over verbatim.  */
  
 -  for (i = 0; i < len0 && !isalpha (encoded[i]); i += 1)
 +  for (i = 0; i < len0 && !isalpha ((unsigned char)encoded[i]); i += 1)
      decoded.push_back (encoded[i]);
  
    at_start_name = 1;
 @@ -1407,7 +1407,7 @@ ada_decode (const char *encoded, bool wr
  	      int op_len = strlen (ada_opname_table[k].encoded);
  	      if ((strncmp (ada_opname_table[k].encoded + 1, encoded + i + 1,
  			    op_len - 1) == 0)
 -		  && !isalnum (encoded[i + op_len]))
 +		  && !isalnum ((unsigned char)encoded[i + op_len]))
  		{
  		  decoded.append (ada_opname_table[k].decoded);
  		  at_start_name = 0;
 @@ -1432,11 +1432,11 @@ ada_decode (const char *encoded, bool wr
  
        if (len0 - i > 5 && encoded [i] == '_' && encoded [i+1] == '_'
  	  && encoded [i+2] == 'B' && encoded [i+3] == '_'
 -	  && isdigit (encoded [i+4]))
 +	  && isdigit ((unsigned char)encoded [i+4]))
  	{
  	  int k = i + 5;
  	  
 -	  while (k < len0 && isdigit (encoded[k]))
 +	  while (k < len0 && isdigit ((unsigned char)encoded[k]))
  	    k++;  /* Skip any extra digit.  */
  
  	  /* Double-check that the "__B_{DIGITS}+" sequence we found
 @@ -1459,11 +1459,11 @@ ada_decode (const char *encoded, bool wr
  	 internally generated.  */
  
        if (len0 - i > 3 && encoded [i] == '_' && encoded[i+1] == 'E'
 -	  && isdigit (encoded[i+2]))
 +	  && isdigit ((unsigned char)encoded[i+2]))
  	{
  	  int k = i + 3;
  
 -	  while (k < len0 && isdigit (encoded[k]))
 +	  while (k < len0 && isdigit ((unsigned char)encoded[k]))
  	    k++;
  
  	  if (k < len0
 @@ -1497,7 +1497,7 @@ ada_decode (const char *encoded, bool wr
  	    i++;
  	}
  
 -      if (wide && i < len0 + 3 && encoded[i] == 'U' && isxdigit (encoded[i + 1]))
 +      if (wide && i < len0 + 3 && encoded[i] == 'U' && isxdigit ((unsigned char)encoded[i + 1]))
  	{
  	  if (convert_from_hex_encoded (decoded, &encoded[i + 1], 2))
  	    {
 @@ -1505,7 +1505,7 @@ ada_decode (const char *encoded, bool wr
  	      continue;
  	    }
  	}
 -      else if (wide && i < len0 + 5 && encoded[i] == 'W' && isxdigit (encoded[i + 1]))
 +      else if (wide && i < len0 + 5 && encoded[i] == 'W' && isxdigit ((unsigned char)encoded[i + 1]))
  	{
  	  if (convert_from_hex_encoded (decoded, &encoded[i + 1], 4))
  	    {
 @@ -1514,7 +1514,7 @@ ada_decode (const char *encoded, bool wr
  	    }
  	}
        else if (wide && i < len0 + 10 && encoded[i] == 'W' && encoded[i + 1] == 'W'
 -	       && isxdigit (encoded[i + 2]))
 +	       && isxdigit ((unsigned char)encoded[i + 2]))
  	{
  	  if (convert_from_hex_encoded (decoded, &encoded[i + 2], 8))
  	    {
 @@ -1523,7 +1523,7 @@ ada_decode (const char *encoded, bool wr
  	    }
  	}
  
 -      if (encoded[i] == 'X' && i != 0 && isalnum (encoded[i - 1]))
 +      if (encoded[i] == 'X' && i != 0 && isalnum ((unsigned char)encoded[i - 1]))
  	{
  	  /* This is a X[bn]* sequence not separated from the previous
  	     part of the name with a non-alpha-numeric character (in other
 @@ -1560,7 +1560,7 @@ ada_decode (const char *encoded, bool wr
    if (operators)
      {
        for (i = 0; i < decoded.length(); ++i)
 -	if (isupper (decoded[i]) || decoded[i] == ' ')
 +	if (isupper ((unsigned char)decoded[i]) || decoded[i] == ' ')
  	  goto Suppress;
      }
  
 @@ -3438,9 +3438,9 @@ encoded_ordered_before (const char *N0, 
      {
        int k0, k1;
  
 -      for (k0 = strlen (N0) - 1; k0 > 0 && isdigit (N0[k0]); k0 -= 1)
 +      for (k0 = strlen (N0) - 1; k0 > 0 && isdigit ((unsigned char)N0[k0]); k0 -= 1)
  	;
 -      for (k1 = strlen (N1) - 1; k1 > 0 && isdigit (N1[k1]); k1 -= 1)
 +      for (k1 = strlen (N1) - 1; k1 > 0 && isdigit ((unsigned char)N1[k1]); k1 -= 1)
  	;
        if ((N0[k0] == '_' || N0[k0] == '$') && N0[k0 + 1] != '\000'
  	  && (N1[k1] == '_' || N1[k1] == '$') && N1[k1 + 1] != '\000')
 @@ -5767,10 +5767,10 @@ is_name_suffix (const char *str)
  
    /* Skip optional leading __[0-9]+.  */
  
 -  if (len > 3 && str[0] == '_' && str[1] == '_' && isdigit (str[2]))
 +  if (len > 3 && str[0] == '_' && str[1] == '_' && isdigit ((unsigned char)str[2]))
      {
        str += 3;
 -      while (isdigit (str[0]))
 +      while (isdigit ((unsigned char)str[0]))
  	str += 1;
      }
    
 @@ -5779,7 +5779,7 @@ is_name_suffix (const char *str)
    if (str[0] == '.' || str[0] == '$')
      {
        matching = str + 1;
 -      while (isdigit (matching[0]))
 +      while (isdigit ((unsigned char)matching[0]))
  	matching += 1;
        if (matching[0] == '\0')
  	return 1;
 @@ -5790,7 +5790,7 @@ is_name_suffix (const char *str)
    if (len > 3 && str[0] == '_' && str[1] == '_' && str[2] == '_')
      {
        matching = str + 3;
 -      while (isdigit (matching[0]))
 +      while (isdigit ((unsigned char)matching[0]))
  	matching += 1;
        if (matching[0] == '\0')
  	return 1;
 @@ -5819,10 +5819,10 @@ is_name_suffix (const char *str)
  #endif
  
    /* _E[0-9]+[bs]$ */
 -  if (len > 3 && str[0] == '_' && str [1] == 'E' && isdigit (str[2]))
 +  if (len > 3 && str[0] == '_' && str [1] == 'E' && isdigit ((unsigned char)str[2]))
      {
        matching = str + 3;
 -      while (isdigit (matching[0]))
 +      while (isdigit ((unsigned char)matching[0]))
  	matching += 1;
        if ((matching[0] == 'b' || matching[0] == 's')
  	  && matching [1] == '\0')
 @@ -5872,17 +5872,17 @@ is_name_suffix (const char *str)
  	    return 1;
  	  return 0;
  	}
 -      if (!isdigit (str[2]))
 +      if (!isdigit ((unsigned char)str[2]))
  	return 0;
        for (k = 3; str[k] != '\0'; k += 1)
 -	if (!isdigit (str[k]) && str[k] != '_')
 +	if (!isdigit ((unsigned char)str[k]) && str[k] != '_')
  	  return 0;
        return 1;
      }
 -  if (str[0] == '$' && isdigit (str[1]))
 +  if (str[0] == '$' && isdigit ((unsigned char)str[1]))
      {
        for (k = 2; str[k] != '\0'; k += 1)
 -	if (!isdigit (str[k]) && str[k] != '_')
 +	if (!isdigit ((unsigned char)str[k]) && str[k] != '_')
  	  return 0;
        return 1;
      }
 @@ -5905,7 +5905,7 @@ is_valid_name_for_wild_match (const char
      return 0;
  
    for (i=0; decoded_name[i] != '\0'; i++)
 -    if (isalpha (decoded_name[i]) && !islower (decoded_name[i]))
 +    if (isalpha ((unsigned char)decoded_name[i]) && !islower ((unsigned char)decoded_name[i]))
        return 0;
  
    return 1;
 @@ -6129,7 +6129,7 @@ ada_lookup_name_info::matches
  	 angle bracket notation.  */
        const char *tmp;
  
 -      for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++);
 +      for (tmp = sym_name; *tmp != '\0' && !isupper ((unsigned char)*tmp); tmp++);
        if (*tmp != '\0')
  	match = false;
      }
 @@ -6244,7 +6244,7 @@ ada_is_ignored_field (struct type *type,
        {
  	/* Wrapper field.  */
        }
 -    else if (isupper (name[0]))
 +    else if (isupper ((unsigned char)name[0]))
        return 1;
    }
  
 @@ -6753,14 +6753,14 @@ ada_scan_number (const char str[], int k
  {
    ULONGEST RU;
  
 -  if (!isdigit (str[k]))
 +  if (!isdigit ((unsigned char)str[k]))
      return 0;
  
    /* Do it the hard way so as not to make any assumption about
       the relationship of unsigned long (%lu scan format code) and
       LONGEST.  */
    RU = 0;
 -  while (isdigit (str[k]))
 +  while (isdigit ((unsigned char)str[k]))
      {
        RU = RU * 10 + (str[k] - '0');
        k += 1;
 @@ -7417,10 +7417,10 @@ field_alignment (struct type *type, int 
  
    len = strlen (name);
  
 -  if (!isdigit (name[len - 1]))
 +  if (!isdigit ((unsigned char)name[len - 1]))
      return 1;
  
 -  if (isdigit (name[len - 2]))
 +  if (isdigit ((unsigned char)name[len - 2]))
      align_offset = len - 2;
    else
      align_offset = len - 1;
 @@ -8998,7 +8998,7 @@ ada_enum_name (const char *name)
      {
        while ((tmp = strstr (name, "__")) != NULL)
  	{
 -	  if (isdigit (tmp[2]))
 +	  if (isdigit ((unsigned char)tmp[2]))
  	    break;
  	  else
  	    name = tmp + 2;
 @@ -9030,7 +9030,7 @@ ada_enum_name (const char *name)
        else
  	return name;
  
 -      if (isascii (v) && isprint (v))
 +      if (isascii ((unsigned char)v) && isprint ((unsigned char)v))
  	storage = string_printf ("'%c'", v);
        else if (name[1] == 'U')
  	storage = string_printf ("'[\"%02x\"]'", v);
 @@ -12542,7 +12542,7 @@ catch_ada_exception_command_split (const
  
    args = skip_spaces (args);
    if (startswith (args, "if")
 -      && (isspace (args[2]) || args[2] == '\0'))
 +      && (isspace ((unsigned char)args[2]) || args[2] == '\0'))
      {
        args += 2;
        args = skip_spaces (args);
 @@ -12815,7 +12815,7 @@ catch_ada_assert_command_split (const ch
  
    /* Check whether a condition was provided.  */
    if (startswith (args, "if")
 -      && (isspace (args[2]) || args[2] == '\0'))
 +      && (isspace ((unsigned char)args[2]) || args[2] == '\0'))
      {
        args += 2;
        args = skip_spaces (args);
 @@ -13216,7 +13216,7 @@ do_full_match (const char *symbol_search
  	      && symbol_search_name[1] == '_')
  	    {
  	      symbol_search_name += 2;
 -	      while (isdigit (*symbol_search_name))
 +	      while (isdigit ((unsigned char)*symbol_search_name))
  		++symbol_search_name;
  	      if (symbol_search_name[0] == '_'
  		  && symbol_search_name[1] == '_')
 Index: dist/gdb/ada-typeprint.c
 ===================================================================
 RCS file: /cvsroot/src/external/gpl3/gdb/dist/gdb/ada-typeprint.c,v
 retrieving revision 1.1.1.11
 diff -u -p -u -r1.1.1.11 ada-typeprint.c
 --- dist/gdb/ada-typeprint.c	12 Aug 2024 21:38:07 -0000	1.1.1.11
 +++ dist/gdb/ada-typeprint.c	25 Jul 2025 12:44:27 -0000
 @@ -72,7 +72,7 @@ decoded_type_name (struct type *type)
        if (s == name_buffer)
  	return name_buffer;
  
 -      if (!islower (s[1]))
 +      if (!islower ((unsigned char)s[1]))
  	return NULL;
  
        for (s = q = name_buffer; *s != '\0'; q += 1)
 
 --Apple-Mail=_52E1FB37-8163-4E28-B245-A16157BF10ED
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=utf-8
 
 
 
 I am not committing this because it is too intrusive, but see if it =
 helps you.
 
 christos
 
 > On Jul 25, 2025, at 6:25=E2=80=AFAM, Thomas Klausner via gnats =
 <gnats-admin%NetBSD.org@localhost> wrote:
 >=20
 > The following reply was made to PR toolchain/59549; it has been noted =
 by GNATS.
 >=20
 > From: Thomas Klausner <wiz%NetBSD.org@localhost>
 > To: gnats-bugs%netbsd.org@localhost
 > Cc:=20
 > Subject: Re: toolchain/59549: gdb is not ctype(3) safe
 > Date: Fri, 25 Jul 2025 12:21:50 +0200
 >=20
 > On Fri, Jul 25, 2025 at 10:20:02AM +0000, RVP via gnats wrote:
 >> (gdb) set demangle-style gnu-v3
 >=20
 > No change, even with both that and language set to c++.
 >  Thomas
 >=20
 
 
 --Apple-Mail=_52E1FB37-8163-4E28-B245-A16157BF10ED--
 
 --Apple-Mail=_2894989C-6E5A-4568-A409-088E55B38E25
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP
 
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org
 
 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCaIN8iQAKCRBxESqxbLM7
 Oj/vAKCrWCDTD2WzD5B0pTe8A5ssQJEGWQCg3Ki54hKccGsZJpQ+o1WbnX0m9OY=
 =0XdV
 -----END PGP SIGNATURE-----
 
 --Apple-Mail=_2894989C-6E5A-4568-A409-088E55B38E25--
 


Home | Main Index | Thread Index | Old Index