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
Original bug ID: 332 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Charles Martin
Version: OCaml 3.01
OS: FreeBSD 4.3-RC
Submission from: adsl-63-195-80-23.dsl.snfc21.pacbell.net (63.195.80.23)
The printf functions use the local function skip_args, defined as:
and skip_args j =
match String.unsafe_get format j with
'0' .. '9' | ' ' | '.' | '-' -> skip_args (succ j)
| c -> j
Since this uses String.unsafe_get, it is possible to make garbage reads
past the end of a malformed format string:
Printf.printf "foo%"
Fix: either use String.get, or check that j < String.length format.
The text was updated successfully, but these errors were encountered:
Full_Name: Charles Martin
Version: OCaml 3.01
OS: FreeBSD 4.3-RC
Submission from: adsl-63-195-80-23.dsl.snfc21.pacbell.net (63.195.80.23)
The printf functions use the local function skip_args, defined as:
and skip_args j =
match String.unsafe_get format j with
'0' .. '9' | ' ' | '.' | '-' -> skip_args (succ j)
| c -> j
Since this uses String.unsafe_get, it is possible to make garbage reads
past the end of a malformed format string:
Printf.printf "foo%"
Fix: either use String.get, or check that j < String.length format.
I don't think you can make garbage reads past the end of the format
string, since a % character has to be followed by a format type
character, and this is verified by the typechecker before the actual
call to printf:
Printf.printf "foo%";;
Bad format `%'
This is arguably error prone, but since the shape of format strings is
fixed and statically known, the skip_args local function is provably
correct, assuming the typechecker correctly verifies all the format
strings of the program (which is mandatory anyway).
Original bug ID: 332
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Charles Martin
Version: OCaml 3.01
OS: FreeBSD 4.3-RC
Submission from: adsl-63-195-80-23.dsl.snfc21.pacbell.net (63.195.80.23)
The printf functions use the local function skip_args, defined as:
and skip_args j =
match String.unsafe_get format j with
'0' .. '9' | ' ' | '.' | '-' -> skip_args (succ j)
| c -> j
Since this uses String.unsafe_get, it is possible to make garbage reads
past the end of a malformed format string:
Fix: either use String.get, or check that j < String.length format.
The text was updated successfully, but these errors were encountered: