Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Emulating public and private in C structs

Name: Anonymous 2010-06-15 11:30

Consider:
foo.h:
struct Foo {
        int public_1;
        int public_2;
}
struct Foo * create_Foo ();
void bar_Foo (struct Foo*);
/* etc */

foo.c:
#include "foo.h"
struct Foo_private {
        struct Foo foo; /* ??? */
        int private_1;
        int private_2;
}
struct Foo * create_Foo (void) {
        return malloc (sizeof(Foo_private));
}
void bar_Foo (struct Foo *foo) {
        Foo_private *foo_p = (Foo_private*) foo; /* ??? */
        /* do whatever with foo_p->private_1 and foo_p->private_2 */
}

Is there anything wrong with this? I'm dubious about the lines commented with ???. I don't want to write getters and setters for the 'public' stuff.

Name: Anonymous 2010-06-17 21:42

>>37
You still haven't explained what ``secure'' even means in this context, and what is gained by it. It's clear you've drunk the Kool-Aid without pausing to consider what it was you were actually consuming.
Jesus fucking christ. Secure means you can create a security context which defines what a set of Java classes are allowed to do (e.g. no reflection, no file access, no access to any classes outside of x.x.x package, etc.), and the VM can enforce this and ensure that the Java bytecode cannot violate these rules - without running in a separate process, without help from the OS (i.e. virtual memory permissions), with a totally shared heap. Without fuck all anything special.

There. Happy now?

>>39
If the attacker has the means to do so, then he's already in control of the system running the VM. This is what I don't understand. No amount of VM trickery will save you in that situation.
What the fuck are you talking about? Anyone can modify .class files after compilation with javac. This won't help you hack through a VM because, wait for it, the Java VM is secure - it can verify bytecode to make sure it doesn't violate any of the rules of its security manager. This is fundamentally impossible in C because it is weakly typed; this is why we have modern memory protection, among many other things, to prevent a badly behaved or malicious program from taking down the OS.

Are you confusing this with JIT compilation? If so, you're an idiot.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List