mirror of
https://github.com/torvalds/linux.git
synced 2026-10-16 04:39:02 +02:00
RFC 5531 assigns only unsigned constants to program, version, and procedure numbers (Section 12.3) and encodes each as an unsigned 32-bit integer (Section 9), so a valid number falls within [0, 2**32 - 1]. RFC 4506 Section 6.2 permits a signed decimal constant for XDR constants in general and sets no ceiling on magnitude, so the grammar accepts an out-of-range value without complaint. It reaches generated code -- a negative procedure number emerges as an enumerator such as "FOO = -5", valid C that compiles cleanly even though the wire field is an unsigned 32-bit integer. Thus the xdrgen front end is the only place that can reject the malformed value. Extend the semantic checks to require each program, version, and procedure number to fall within [0, 2**32 - 1]. Link: https://patch.msgid.link/20260712203451.124902-6-cel@kernel.org Signed-off-by: Chuck Lever <cel@kernel.org>
20 lines
583 B
Plaintext
20 lines
583 B
Plaintext
/*
|
|
* NEGATIVE TEST CASE -- xdrgen must REJECT this specification.
|
|
*
|
|
* RFC 5531 assigns only unsigned constants to program, version, and
|
|
* procedure numbers (Section 12.3). This spec gives the program a
|
|
* negative number, which the front end must reject.
|
|
*
|
|
* Expected diagnostic:
|
|
* negative program number -100000 in program 'BADPROG'
|
|
*
|
|
* The tests directory has no automated runner; exercise by hand:
|
|
* ./xdrgen definitions tests/bad-program-number-negative.x (must fail)
|
|
*/
|
|
|
|
program BADPROG {
|
|
version BADVERS {
|
|
void BADPROC_NULL(void) = 0;
|
|
} = 1;
|
|
} = -100000;
|