Re: Using pointers across several network clients



On Dec 5, 12:19 pm, Andreas Wittmann <andreas.wittm...@xxxxxxx> wrote:
Hello NG!

The following situation:
I have a server (over network) application which allocates different
pointers to several data structures in it's own memory.

Some network clients should now be able to access those structures (At
least a handle to tell the server which structure to use for the internal
operations of the server).

My question:
Is it a clean design if i'm directly using the pointer of the server data
structures and treat them like a "data-handle" for the client? Some self-
written functions would operate on such "handles" and the server itself
also check's if the pointer's, which came from the clients, are valid
before using.

How can you know whether the pointers are valid? You can maybe check
that they don't point outside the program's address space (though this
is usually inconvenient and non-portable) but there's no way to know
that they actually point to an object of the desired type. A
malicious client might give you a pointer that points to something
totally different, that you don't want to mess with.

I know that different machines have different sizes for pointer's (int on
x86, ...) - but this doesn't matter, at least not for this project.

It's a question of time. I'm working on an existing, time-critical,
project and updates/bugfixes should be implemented as fast as possible.
But i don't wan't to produce unreadable code or security leaks.

Don't do this. It strikes me as dangerous and extremely ugly.

It should be quite simple to keep a table of your objects, with only
an index or key into the table being passed back and forth. It could
be a flat array, if there are a small number and you don't have to do
a lot of adding and deleting, or it could be something like C++'s
std::map. I bet it will take you less time to implement than it did
to write your post and read the replies.
.



Relevant Pages

  • logon and network drive access slow after firewall
    ... This is a Windows 2000 server with mostly XP clients and some windows 98 clients ... The W2K Server is on SP3 ... Logon is slow Drive access is slow access to files and printing is also slow. ... I would appreciate any pointers on this. ...
    (microsoft.public.win2000.networking)
  • Re: unix local domain, signals, and locking help!
    ... > two clients attempt to connect to the server at the same time, ... multithreaded program using POSIX threads ... You only need to lock the data structures ... list of client connections held by the server. ...
    (comp.unix.programmer)
  • mmap file at fixed address
    ... For this reason I build in a cache, ... everytime the server is restarted. ... this cache is nothing more that some fixed size data structures, ... So when I map the file the next time, the pointers in ...
    (comp.os.linux.development.apps)
  • Re: [freebsd-isp] Re: BW measuring Tool
    ... one Tuc mentions, only being US the server and our customers the clients, ... pointers where to look for. ...
    (freebsd-isp)
  • Using pointers across several network clients
    ... I have a server application which allocates different ... pointers to several data structures in it's own memory. ... Some network clients should now be able to access those structures (At ...
    (comp.unix.programmer)