Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#1132 closed bug (invalid)

Data.ByteString.Lazy.Char8's readInt does no bounds checking

Reported by: bos Owned by:
Priority: normal Milestone:
Component: hslibs/data Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

I think it should be failing with Nothing if given a string of digits that's too long.

~ $ ghci
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __  / /___| |
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> :m +Data.ByteString.Lazy.Char8 
Prelude Data.ByteString.Lazy.Char8> readInt (pack "99999999999999999999")
Just (7766279631452241919,LPS [])

Change History (6)

comment:1 Changed 11 years ago by bos

Hmm, guess I can't use WikiFormatting after all. Sorry for the mess!

comment:2 Changed 11 years ago by bos

Don points out that this behaviour is consistent with that of read, so depending on your perspective, we have either one bug (in two places), two bugs, or no bugs :-)

comment:3 Changed 11 years ago by igloo

Description: modified (diff)
Resolution: invalid
Status: newclosed

Haskell doesn't define overflow behaviour, so I think this is no bugs.

comment:4 Changed 9 years ago by simonmar

Architecture: MultipleUnknown/Multiple

comment:5 Changed 9 years ago by simonmar

Operating System: MultipleUnknown/Multiple

comment:6 Changed 8 years ago by simonmar

difficulty: Easy (1 hr)Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.