OSCON 2012 notes
Paulo Pinto
pjmlp at progtools.org
Sun Jul 22 12:13:02 PDT 2012
Am 22.07.2012 20:46, schrieb Nick Sabalausky:
> On Sun, 22 Jul 2012 18:14:23 +0200
> Paulo Pinto<pjmlp at progtools.org> wrote:
>> y :=&x[0]
>> fmt.Println("Base adress ", y)
>> size := unsafe.Sizeof(x[0])
>> fmt.Println("Size per element ", size)
>> for i := 0; i< len(x); i++ {
>> cell := uint64(uintptr(unsafe.Pointer(y))) +
>> (uint64(i) * uint64(size)) value :=
>> (*byte)(unsafe.Pointer(uintptr(cell))) fmt.Printf("%d index is %d, at
>> %p\n", i, *value, value) }
>> }
>>
>
> Eeew!! That's awful.
>
Pointer arithmetic as endless source for security exploits is to be used
*only* when no other solution exists.
But yes, the way to do it could be simpler.
More information about the Digitalmars-d
mailing list