From hb at stat.berkeley.edu  Sat Apr  7 23:51:22 2007
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Sat, 7 Apr 2007 14:51:22 -0700
Subject: [Rd] readBin() can read beyond end of raw vector
Message-ID: <59d7961d0704071451m590e037cjb3673e25906e1812@mail.gmail.com>

FYI, in R v2.5.0 alpha, readBin() can be used to read beyond end of raw vector:

> bfr <- as.raw(1:10)
> readBin(con=bfr, what="raw", n=20)
 [1] 01 02 03 04 05 06 07 08 09 0a

> readBin(con=bfr, what="integer", n=20)
[1]  67305985 134678021

> readBin(con=bfr, what="integer", size=4, n=20)
[1]  67305985 134678021

> readBin(con=bfr, what="integer", size=2, n=20)
 [1]    513   1027   1541   2055   2569  29537  29541      0      9  16384
[11]   9376    453 -18208    505 -18328    505      9      0      0      0

> readBin(con=bfr, what="integer", size=1, n=20)
 [1]   1   2   3   4   5   6   7   8   9  10  97 115 101 115   0   0   9   0   0
[20]  64

> sessionInfo()
R version 2.5.0 alpha (2007-04-04 r41043)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON
ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
[7] "base"

/Henrik



[Rd] readBin() can read beyond end of raw vector
Henrik Bengtsson