Bug 2256912 - libsmi: Suspicious type error in Bison parser will lead to build failure
Summary: libsmi: Suspicious type error in Bison parser will lead to build failure
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: libsmi
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PortingToModernCExemptions
TreeView+ depends on / blocked
 
Reported: 2024-01-05 07:40 UTC by Florian Weimer
Modified: 2024-01-21 18:17 UTC (History)
3 users (show)

Fixed In Version: libsmi-0.4.8-37.fc40
Clone Of:
Environment:
Last Closed: 2024-01-21 18:17:30 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Florian Weimer 2024-01-05 07:40:58 UTC
GCC 14 will fail to build this package with an error like this:

parser-sming.y:2164:89: error: passing argument 2 of 'setAttributeList' makes pointer from integer without a cast
 2164 |                                 setAttributeList($$, $1);
      |                                                                                         ^   
      |                                                                                         |
      |                                                                                         int
In file included from error.h:17,
                 from parser-sming.y:39:
data.h:703:61: note: expected 'List *' but argument is of type 'int'
  703 | extern void setAttributeList(Attribute *attributePtr, List *listPtr);
      |                                                       ~~~~~~^~~~~~~
parser-sming.y:2165:40: error: assignment to 'List *' from 'int' makes pointer from integer without a cast
 2165 |                                 for (p = $1; p; p = p->nextPtr)
      |                                        ^

This comes from the handler for the bits keyword in lib/parser-sming.y:

	|		BitsKeyword 
			{
				bitsFlag = 1; //Since Enum elements can be 
							  //negative we must make sure
							  //that bits is not negative,
							  //so we raise bitsFlag and
							  //give error if there is
							  //negative value 
			}
			bitsOrEnumerationSpec
			{
			    List *p;
			    
			    $$ = duplicateTypeToAttribute(smiHandle->typeBitsPtr,
							  classPtr, thisParserPtr);
			    setAttributeParentType($$, smiHandle->typeBitsPtr);
			    if ($1) {
				setAttributeList($$, $1);
				for (p = $1; p; p = p->nextPtr)
				    ((NamedNumber *)(p->ptr))->typePtr = (Type*)$$;
			    }
			    
			    bitsFlag = 0; /* reset flag */
			}


I don't know how to fix this properly. The types appear to line up properly in the Bison grammar source.

Reproducible: Always

Comment 1 Tom "spot" Callaway 2024-01-05 17:00:37 UTC
Because you've been in this package before, you know how old and crufty it is.

That said, I went upstream and found that they had actually been making changes over the last ... 10 years? So, I rebased the sources Fedora uses and made some cleanups that seemed obviously correct to me.

It's not at all clear who (if anyone) is using libsmi in 2024. Upstream hadn't made meaningful changes in several years, so we could probably retire this package with minimal impact if we needed to (I think wireshark is the only Fedora consumer).

That said, toss gcc 14 at libsmi-0.4.8-35.fc40 (current in rawhide) and see if it fails in the same way (or in other ways)?

Comment 2 Florian Weimer 2024-01-08 08:29:56 UTC
Unfortunately, the errors are still there:

parser-sming.y:2158:82: error: passing argument 2 of 'setAttributeList' makes pointer from integer without a cast
 2158 |                                 setAttributeList($$, $1);
      |                                                                                  ^   
      |                                                                                  |
      |                                                                                  int
smi-data.h:705:61: note: expected 'List *' but argument is of type 'int'
  705 | extern void setAttributeList(Attribute *attributePtr, List *listPtr);
      |                                                       ~~~~~~^~~~~~~
parser-sming.y:2159:40: error: assignment to 'List *' from 'int' makes pointer from integer without a cast
 2159 |                                 for (p = $1; p; p = p->nextPtr)
      |                                        ^
parser-sming.y:2198:44: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
 2198 |                                 } else if (tmp = findClass($1,
      |                                            ^~~


I suppose we can add an exemption once GCC 14 lands, but I think this is really a parser bug, leading to a crash if this syntax is ever used in the input.

Comment 3 Florian Weimer 2024-01-21 18:17:30 UTC
As we can't rebuild this parser from source, I've downgraded the type safety level for this package.


Note You need to log in before you can comment on or make changes to this bug.