You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parser currently uses Int64.of_string and Int32.of_string to parse 64 bit and 32 bit integers, respectively. However, these functions parse signed integers in the range [-2^(x-1), 2^(x-1)-1] for x = 32,64. What we want are unsigned integers in the range [0,2^x-1]. The functions to_int and to_int32 in Frenetic_Fdd.ml suffer from a similar problem, see @calebvoss's comment in #517.
The deeper issue here is that we're using signed types int, int32, and int64 throughout the code base when really we should be using uint, uint32, and uint64. This would avoid bugs of this nature. Unfortunately, OCaml does not support these types natively, so we will need to resort to some library.
The text was updated successfully, but these errors were encountered:
smolkaj
changed the title
NetKAT parses *signed* 32/64bit integers; should be *unsigned*
NetKAT parses signed 32/64bit integers; should be unsigned
Dec 14, 2016
The stdint packages provides various unsigned integer types together with parsing functions etc., but they currently don't have support for s-expressions, see andrenth/ocaml-stdint#10.
The parser currently uses
Int64.of_string
andInt32.of_string
to parse 64 bit and 32 bit integers, respectively. However, these functions parse signed integers in the range [-2^(x-1), 2^(x-1)-1] for x = 32,64. What we want are unsigned integers in the range [0,2^x-1]. The functionsto_int
andto_int32
inFrenetic_Fdd.ml
suffer from a similar problem, see @calebvoss's comment in #517.The deeper issue here is that we're using signed types
int
,int32
, andint64
throughout the code base when really we should be usinguint
,uint32
, anduint64
. This would avoid bugs of this nature. Unfortunately, OCaml does not support these types natively, so we will need to resort to some library.The text was updated successfully, but these errors were encountered: