From 0d9dcb2f4f16b0bc00c21f1cf23a0fadbcb425ba Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 25 Jul 2014 09:01:54 +0200 Subject: [PATCH] Remove file count and size limits in protocol --- protocol/message.go | 6 +++--- protocol/message_xdr.go | 16 ++-------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/protocol/message.go b/protocol/message.go index 4b61932f5..3d6370a4f 100644 --- a/protocol/message.go +++ b/protocol/message.go @@ -7,8 +7,8 @@ package protocol import "fmt" type IndexMessage struct { - Repository string // max:64 - Files []FileInfo // max:10000000 + Repository string // max:64 + Files []FileInfo } type FileInfo struct { @@ -17,7 +17,7 @@ type FileInfo struct { Modified int64 Version uint64 LocalVersion uint64 - Blocks []BlockInfo // max:1000000 + Blocks []BlockInfo } func (f FileInfo) String() string { diff --git a/protocol/message_xdr.go b/protocol/message_xdr.go index 83367bacc..32f64b51d 100644 --- a/protocol/message_xdr.go +++ b/protocol/message_xdr.go @@ -38,7 +38,7 @@ IndexMessage Structure: struct IndexMessage { string Repository<64>; - FileInfo Files<10000000>; + FileInfo Files<>; } */ @@ -64,9 +64,6 @@ func (o IndexMessage) encodeXDR(xw *xdr.Writer) (int, error) { return xw.Tot(), xdr.ErrElementSizeExceeded } xw.WriteString(o.Repository) - if len(o.Files) > 10000000 { - return xw.Tot(), xdr.ErrElementSizeExceeded - } xw.WriteUint32(uint32(len(o.Files))) for i := range o.Files { o.Files[i].encodeXDR(xw) @@ -88,9 +85,6 @@ func (o *IndexMessage) UnmarshalXDR(bs []byte) error { func (o *IndexMessage) decodeXDR(xr *xdr.Reader) error { o.Repository = xr.ReadStringMax(64) _FilesSize := int(xr.ReadUint32()) - if _FilesSize > 10000000 { - return xdr.ErrElementSizeExceeded - } o.Files = make([]FileInfo, _FilesSize) for i := range o.Files { (&o.Files[i]).decodeXDR(xr) @@ -139,7 +133,7 @@ struct FileInfo { hyper Modified; unsigned hyper Version; unsigned hyper LocalVersion; - BlockInfo Blocks<1000000>; + BlockInfo Blocks<>; } */ @@ -169,9 +163,6 @@ func (o FileInfo) encodeXDR(xw *xdr.Writer) (int, error) { xw.WriteUint64(uint64(o.Modified)) xw.WriteUint64(o.Version) xw.WriteUint64(o.LocalVersion) - if len(o.Blocks) > 1000000 { - return xw.Tot(), xdr.ErrElementSizeExceeded - } xw.WriteUint32(uint32(len(o.Blocks))) for i := range o.Blocks { o.Blocks[i].encodeXDR(xw) @@ -197,9 +188,6 @@ func (o *FileInfo) decodeXDR(xr *xdr.Reader) error { o.Version = xr.ReadUint64() o.LocalVersion = xr.ReadUint64() _BlocksSize := int(xr.ReadUint32()) - if _BlocksSize > 1000000 { - return xdr.ErrElementSizeExceeded - } o.Blocks = make([]BlockInfo, _BlocksSize) for i := range o.Blocks { (&o.Blocks[i]).decodeXDR(xr)