Skip to content

Commit

Permalink
Fix building for 32bit architectures
Browse files Browse the repository at this point in the history
The code was previously assuming that int type was always int64. This
caused us to fail to build for 32bit systems where we were doing a
check against MaxUint32.

We now explicitly cast the value to int64 prior to doing the check. On
32bit systems this is fine because the length of the array can't be
larger than MaxInt32.

Fixes: #1
  • Loading branch information
psanford committed Sep 10, 2019
1 parent e083989 commit 6689c61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wormhole/file_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ func (d *transportCryptor) writeRecord(msg []byte) error {

nonceAndSealedMsg := append(nonce[:], sealedMsg...)

if len(nonceAndSealedMsg) >= math.MaxUint32 {
// we do an explit cast to int64 to avoid compilation failures
// for 32bit systems.
nonceAndSealedMsgSize := int64(len(nonceAndSealedMsg))

if nonceAndSealedMsgSize >= math.MaxUint32 {
panic(fmt.Sprintf("writeRecord too large: %d", len(nonceAndSealedMsg)))
}

Expand Down

0 comments on commit 6689c61

Please sign in to comment.