Skip to content

Commit 2df4d68

Browse files
authored
Merge pull request #109 from mirage/restrictive
Be restrictive about that Ipaddr.of_string accepts
2 parents b5d92b2 + f61d522 commit 2df4d68

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/ipaddr.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,12 @@ let of_string_raw s offset =
10051005
in
10061006
raise (Parse_error (msg, s))))
10071007

1008-
let of_string_exn s = of_string_raw s (ref 0)
1008+
let of_string_exn s =
1009+
let o = ref 0 in
1010+
let x = of_string_raw s o in
1011+
expect_end s o;
1012+
x
1013+
10091014
let of_string s = try_with_result of_string_exn s
10101015

10111016
let v6_of_v4 v4 =
@@ -1087,7 +1092,12 @@ module Prefix = struct
10871092
in
10881093
raise (Parse_error (msg, s))))
10891094

1090-
let of_string_exn s = of_string_raw s (ref 0)
1095+
let of_string_exn s =
1096+
let o = ref 0 in
1097+
let x = of_string_raw s o in
1098+
expect_end s o;
1099+
x
1100+
10911101
let of_string s = try_with_result of_string_exn s
10921102

10931103
let v6_of_v4 v4 =

0 commit comments

Comments
 (0)