diff mbox series

xyzModem: Correct xmodem blk verification conditions

Message ID 20240206024925.16325-1-jhb_ee@163.com
State Superseded
Delegated to: Tom Rini
Headers show
Series xyzModem: Correct xmodem blk verification conditions | expand

Commit Message

jihongbin Feb. 6, 2024, 2:49 a.m. UTC
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.

Signed-off-by: Hongbin Ji <jhb_ee@163.com>
---
 common/xyzModem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

jihongbin Feb. 6, 2024, 12:20 p.m. UTC | #1
This is a duplicate, please ignore

在 2024/2/6 10:49, 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.
>
> Signed-off-by: Hongbin Ji <jhb_ee@163.com>
> ---
>   common/xyzModem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/xyzModem.c b/common/xyzModem.c
> index fb319f7119..0bc1a87067 100644
> --- a/common/xyzModem.c
> +++ b/common/xyzModem.c
> @@ -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,
Tom Rini Feb. 6, 2024, 1:48 p.m. UTC | #2
On Tue, Feb 06, 2024 at 10:49:25AM +0800, Hongbin Ji wrote:

> 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.
> 
> Signed-off-by: Hongbin Ji <jhb_ee@163.com>
> ---
>  common/xyzModem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/xyzModem.c b/common/xyzModem.c
> index fb319f7119..0bc1a87067 100644
> --- a/common/xyzModem.c
> +++ b/common/xyzModem.c
> @@ -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.
diff mbox series

Patch

diff --git a/common/xyzModem.c b/common/xyzModem.c
index fb319f7119..0bc1a87067 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -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,