[Rd] %s in filename when opening device causes crash (PR#10571)

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Wed Jan 16 11:56:16 CET 2008


Richard Cotton wrote:
>
> Prof Brian Ripley wrote:
>   
>>> Yes. The problem is of course that we do want a sprintf() format there
>>> for "Rplot%03d.pdf" et al. One  option would be to escape "%" except
>>> when in (regexp) "%[0-9]*d", which seems nontrivial, but not impossible.
>>>       
>> But there are other integer formats (%i, %u, %x, %X), and other flags (# 
>> might be useful).  So the list of valid inputs is also rather long.  It 
>> would be tedious to do at C level, but a check in the R-level wrapper 
>> would be easier (if not 'simple').
>>
>>     
>
> Having just worked my way through the alphabet, I can say that it is only
> the letters 's' and 'n' that cause any problems.  Thus, if you do decide to
> handle the error in the R wrapper functions, the regex for bad inputs is
> fairly straightforward "%[#[:blank:]\\+\\-]*[[:digit:]]*[sn]".
>   
Not quite. The floating point formats are also problematic; you may
fetch 8 bytes where only 4 was allocated. Also, %%s should not be
forbidden. Anyways, I believe Brian has this in hand.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list