Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

JavaScript Bug - deserializeBinary uint64 field to a unsafe int and not correct number

未关闭
#67 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
javascript

调研方向

从 InitConnect.proto 中的 uint64 字段开始,跟踪生成的 InitConnect_pb.js,经过 Response.deserializeBinary() 和 toObject()。确定应如何表示超出 Number.MAX_SAFE_INTEGER 的值,然后验证 connID 往返时不会改变原始值。

由索引模型根据 Issue 内容生成。

描述

bug javascript triaged

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

protocolbuffers/protobuf-javascript 的其他 Issue

查看 protocolbuffers/protobuf-javascript 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。