unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#12095: Protecting pointer on bytevector with guardian does not protect memory
@ 2012-07-30 16:01 Patrick Bernaud
  2012-08-06 16:37 ` Ian Price
  0 siblings, 1 reply; 10+ messages in thread
From: Patrick Bernaud @ 2012-07-30 16:01 UTC (permalink / raw)
  To: 12095

[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 658 bytes --]


The memory from a bytevector of which a pointer is taken (with
'bytevector->pointer') can be overwritten even if that pointer has
been put inside a guardian. 'make-c-struct' from (system foreign) is
using 'bytevector->pointer'.

With the test script attached:

$ guile -v | head -1
guile (GNU Guile) 2.0.6.8-cc26b9-dirty
$ guile --no-auto-compile -s test.scm
#<pointer 0x974648c>
#vu8(1 1 1 1 1 1 1 1 1 1)
#vu8(1 1 1 1 1 1 1 1 1 1)
#vu8(110 103 45 108 101 110 103 116 104 0)  <<<< memory overwrite with "ng-length\0" from module
#<pointer 0x974648c>
$

With auto compilation turned on, it looks like the problem can not be
reproduced.

-- 
Patrick Bernaud


[-- Attachment #2: test.scm --]
[-- Type: application/octet-stream, Size: 526 bytes --]

(use-modules (system foreign) (rnrs bytevectors))
(define my-guardian (make-guardian))
(define len 10)
(define x (bytevector->pointer (make-bytevector len 1)))
(define a (pointer-address x))
(display x)(newline)
(my-guardian x)
;(my-guardian (pointer->bytevector x len))
(set! x #f)
(write (pointer->bytevector (make-pointer a) len))(newline)
(gc)
(write (pointer->bytevector (make-pointer a) len))(newline)
(use-modules (htmlprag))
(write (pointer->bytevector (make-pointer a) len))(newline)
(display (my-guardian))(newline)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-10-08 15:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-30 16:01 bug#12095: Protecting pointer on bytevector with guardian does not protect memory Patrick Bernaud
2012-08-06 16:37 ` Ian Price
2012-08-07  3:32   ` Daniel Hartwig
2012-10-06 21:41     ` Ludovic Courtès
2012-10-07  2:56       ` Daniel Hartwig
2012-10-07 20:38         ` Ludovic Courtès
2012-10-07 23:49           ` Daniel Hartwig
2012-10-08 13:44             ` Ludovic Courtès
2012-10-08 14:10               ` Daniel Hartwig
2012-10-08 15:42                 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).