Skip to contentSkip to conversation

xyzModem: Correct xmodem blk verification conditions

PATCH In review Hongbin Ji 2 participants 3 messages Feb 6, 2024

lore
Share & tools
lore

Hongbin Ji

author
#0 lore raw

PATCH 1/1 xyzModem: Correct xmodem blk verification conditions

When the blk sequence number is 255 and cblk is 0, the original XOR condition produces a result of 0,and the judgment condition will be unsuccessful.

---
 common/xyzModem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/xyzModem.c +1 -1
index fb319f7119..0bc1a87067 100644
@@ -373,7 +373,7 @@ xyzModem_get_hdr (void)
     }
   ZM_DEBUG (zm_dump (__LINE__));
   /* Validate the message */
-  if ((xyz.blk ^ xyz.cblk) != (unsigned char) 0xFF)
+  if (~xyz.blk != xyz.cblk)
     {
       ZM_DEBUG (zm_dprintf
 		("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 13 lines · Hongbin Ji

When the blk sequence number is 255 and cblk is 0, the original XOR condition produces a result of 0,and the judgment condition will be unsuccessful.

---
 common/xyzModem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/xyzModem.c +0 -0
index fb319f7119..0bc1a87067 100644

common/xyzModem.c xyzModem_get_hdr (void) · line 379

Quoted 8 lines
common/xyzModem.c +1 -1
@@ -373,7 +373,7 @@ xyzModem_get_hdr (void)
     }
   ZM_DEBUG (zm_dump (__LINE__));
   /* Validate the message */
-  if ((xyz.blk ^ xyz.cblk) != (unsigned char) 0xFF)
+  if (~xyz.blk != xyz.cblk)
     {
       ZM_DEBUG (zm_dprintf
 		("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,

As Dan noted before, this is very old code. Is there a problem you're encountering in the real world? What has brought you to see a problem and make a change here? Thanks.

Signature · 1 line
Tom
author
#2 lore raw
In reply to Hongbin Ji

This is a duplicate, please ignore

Quoted 21 lines · Hongbin Ji

When the blk sequence number is 255 and cblk is 0, the original XOR condition produces a result of 0,and the judgment condition will be unsuccessful.

---
  common/xyzModem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
common/xyzModem.c +1 -1
index fb319f7119..0bc1a87067 100644
@@ -373,7 +373,7 @@ xyzModem_get_hdr (void)
      }
    ZM_DEBUG (zm_dump (__LINE__));
    /* Validate the message */
-  if ((xyz.blk ^ xyz.cblk) != (unsigned char) 0xFF)
+  if (~xyz.blk != xyz.cblk)
      {
        ZM_DEBUG (zm_dprintf
  		("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,