Indy接收邮件可能发生range check error错误的修正

使用D2010,接收邮件时有时会发生range check error的错误,而foxmail则可以正常接收,估计是indy本身的bug,追踪了一下,发现错误出现在IdCoder3to4.pas中的第277行:

Result[LOutPos]     := (FDecodeTable[LInBytes[0]] shl 2) or ((FDecodeTable[LInBytes[1]] shr 4) and 3);
抱着试试看的方式google了一下,在Embarcdero的论坛上竟然有人提这个bug了:

https://forums.embarcadero.com/message.jspa?messageID=192364

内容如下:

In \Protocols\IdCoder3to4.pas line 277

     
     Result[LOutPos]     := (FDecodeTable[LInBytes[0]] shl 2) or ((FDecodeTable[LInBytes[1]] shr 4) and 3);
     Result[LOutPos + 1] := ((FDecodeTable[LInBytes[1]] and 15) shl 4) or ((FDecodeTable[LInBytes[2]] shr 2) and 15);
     Result[LOutPos + 2] := ((FDecodeTable[LInBytes[2]] and 3) shl 6) or (FDecodeTable[LInBytes[3]] and 63);


When the base64 data contains, for whatever reason, garbage (for instance
a space as first character) above code will generate a range-check error.

In case of a space FDecodeTable[LInBytes[0]] will return 255, which is
then "shifted" by two times add eax, eax.

Suggested change:
     
     Result[LOutPos]     := ((FDecodeTable[LInBytes[0]] and 63) shl 2) or ((FDecodeTable[LInBytes[1]] shr 4) and 3);
...
Thanks, I have checked it in.

--
Remy Lebeau (TeamB)
 
可能在下个版本中能修正这个问题.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值