JavaScript Bug - deserializeBinary uint64 field to a unsafe int and not correct number
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
从 InitConnect.proto 中的 uint64 字段开始,跟踪生成的 InitConnect_pb.js,经过 Response.deserializeBinary() 和 toObject()。确定应如何表示超出 Number.MAX_SAFE_INTEGER 的值,然后验证 connID 往返时不会改变原始值。
由索引模型根据 Issue 内容生成。
描述
I use protoc-3.6.0-osx-x86_64 to convert xx.proto to xx_pb.js and npm install google-protobuf(^3.6.0)
InitConnect.proto
syntax = "proto2";
package InitConnect;
import "Common.proto";
message C2S
{
required int32 clientVer = 1; //客户端版本号,clientVer = "."以前的数 * 100 + "."以后的,举例:1.1版本的clientVer为1 * 100 + 1 = 101,2.21版本为2 * 100 + 21 = 221
required string clientID = 2; //客户端唯一标识,无生具体生成规则,客户端自己保证唯一性即可
optional bool recvNotify = 3; //此连接是否接收市场状态、交易需要重新解锁等等事件通知,true代表接收,FutuOpenD就会向此连接推送这些通知,反之false代表不接收不推送
}
message S2C
{
required int32 serverVer = 1; //FutuOpenD的版本号
required uint64 loginUserID = 2; //FutuOpenD登陆的牛牛用户ID
required uint64 connID = 3; //此连接的连接ID,连接的唯一标识
required string connAESKey = 4; //此连接后续AES加密通信的Key,固定为16字节长字符串
required int32 keepAliveInterval = 5; //心跳保活间隔
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //返回结果,参见Common.RetType的枚举定义
optional string retMsg = 2; //返回结果描述
optional int32 errCode = 3; //错误码,客户端一般通过retType和retMsg来判断结果和详情,errCode只做日志记录,仅在个别协议失败时对账用
optional S2C s2c = 4;
}
I convert InitConnect.proto to InitConnect_pb.js And Import it to node.js code
const InitConnectMessage = require("InitConnect_pb.js")
//I get PackageBody_Buffer from net, then deserializeBinary
let ResponseBody_Object = InitConnectMessage.Response.deserializeBinary(PackageBody_Buffer);
ResponseBody_Object = ResponseBody_Object.toObject();
console.log(ResponseBody_Object)
The log is :
{ rettype: 0,
retmsg: '',
errcode: 0,
s2c:
{ serverver: 100,
loginuserid: 2131552,
connid: 167141872653707230,
connaeskey: 'D7279ECAA5CF51E8',
keepaliveinterval: 10 } }
As the result, the deserialized connid is 167141872653707230, more than js Number.MAX_SAFE_INTEGER// → 9_007_199_254_740_991
Moreover the deserialized connid is not equal to the original connid!
- 主要语言
- JavaScript
- 星标
- 471
- 派生
- 91
- 平均合并
- 3 小时 57 分钟
- 30 天内合并 PR
- 2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
protocolbuffers/protobuf-javascript 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 5/5 一周以上 新手友好度 30/100
protocolbuffers/protobuf-javascript#248 · 1 条评论 · 13 个 reaction ·
-
question
难度 3/5 1-2 天 新手友好度 45/100
protocolbuffers/protobuf-javascript#222 · 9 条评论 ·
-
enhancement port-fix triaged
难度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#185 · 1 条评论 ·
-
enhancement port-fix triaged
难度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#182 · 3 条评论 · 1 个 reaction ·
查看 protocolbuffers/protobuf-javascript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
antfu-collective/icones#398 ·
-
ECmail.com 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
wesbos/burner-email-providers#554 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
radiantearth/stac-browser#1023 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
components-web-app/docs#92 ·