#6789 closed bug (fixed)
Wrong comparison in tcp add-on
Reported by: | kaliber | Owned by: | stippi |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Network & Internet/TCP | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Here is clang diagnose:
src/add-ons/kernel/network/protocols/tcp/tcp.cpp:201:43: error: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] if (option->length == 4 && (size - 4) >= 0) ~~~~~~~~~~ ^ ~ src/add-ons/kernel/network/protocols/tcp/tcp.cpp:205:43: error: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] if (option->length == 3 && (size - 3) >= 0) { ~~~~~~~~~~ ^ ~ src/add-ons/kernel/network/protocols/tcp/tcp.cpp:211:45: error: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] if (option->length == 10 && (size - 10) >= 0) { ~~~~~~~~~~~ ^ ~ src/add-ons/kernel/network/protocols/tcp/tcp.cpp:219:43: error: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] if (option->length == 2 && (size - 2) >= 0) ~~~~~~~~~~ ^ ~
Attachments (1)
Change History (6)
by , 14 years ago
Attachment: | tcp-wrong-comparison.patch added |
---|
comment:1 by , 14 years ago
patch: | 0 → 1 |
---|
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → in-progress |
I've looked into the problem and your patch is not a good solution. The length from the option is used regardless of those comparisions. If size happens not to be a multiple of the option length (which may be checked elsewhere in the code, I don't know), then the loop will overflow (wrap) the size variable. I will commit a different fix.
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | in-progress → closed |
Should be fixed in hrev39309.
comment:4 by , 14 years ago
Actually, I think kaliber's patch was just fine. If you look at the caller of process_options(), the size cannot be smaller than 0.
His patch also makes the code more readable; I'm going to apply it later.
comment:5 by , 14 years ago
Patch applied, and stippi's issue fixed differently in hrev39311. Thanks everyone!
proposed patch