Copilot commented on code in PR #3593:
URL: https://github.com/apache/brpc/pull/3593#discussion_r4228472692


##########
src/brpc/amf.cpp:
##########
@@ -392,6 +392,12 @@ bool ReadAMFUint32(uint32_t* val, AMFInputStream* stream) {
     if (!ReadAMFNumber(&d, stream)) {
         return false;
     }
+    // The number comes from the peer and may be NaN or out of [0, UINT32_MAX],
+    // for which the conversion below is undefined. The check is false for NaN.
+    if (!(d >= 0.0 && d <= 4294967295.0)) {

Review Comment:
   This guard changes defined behavior for fractional values just outside the 
integer endpoints. Floating-to-integer conversion truncates first, so `-0.5` 
previously (and validly) produced `0`, while `4294967295.5` produced 
`UINT32_MAX`; the new test also confirms that truncation of `42.5` remains part 
of this API. To remove only the undefined conversions as claimed, accept the 
open interval `(-1, 2^32)` and add these two boundary cases to the good-value 
test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to