Bug 2256912

Summary: libsmi: Suspicious type error in Bison parser will lead to build failure
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: libsmiAssignee: Tom "spot" Callaway <spotrh>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: jsafrane, rvokal, spotrh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libsmi-0.4.8-37.fc40 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-01-21 18:17:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2137516    

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.