Commit Graph

47 Commits (5a991e1fcbcdcca9a191c8e377b4cfb89142761e)

Author SHA1 Message Date
Vitaliy Filippov 5a991e1fcb Do not try to ZDR_DECODE bytes into a preallocated buffer (it also segfaults) 2022-02-12 14:09:40 +03:00
Vitaliy Filippov d1999dc956 Don't try to ZDR_DECODE strings into a pre-existing pointer
Otherwise it segfaults inside any string decoding inside rpc_process_call()
as it doesn't zero the allocated memory, so libnfs_zdr_string() may receive
non-zero *strp which is very easy to reproduce by writing a simple NFS server
example using libnfs :-)
2021-10-11 00:55:14 +03:00
Ronnie Sahlberg f965ec74cf ps2ee: PS2 EE support
Initial support for building a library for PS2 EmotionEngine

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-09-17 07:27:44 +10:00
Damian c14a5acb51 Porting to PS3 2020-08-14 19:30:00 -03:00
Damian c7ad0762d8 Porting library to PS3 (psl1ght) 2020-08-14 11:47:39 -03:00
DetlefGolze b9c85afc4f
Update libnfs-zdr.c
libnfs_zdr_array() needs to determine element count before calculating size to allocate.
2020-05-06 10:51:39 +02:00
Volker Lendecke 338837f6de Simplify range check in libnfs_zdr_array
Signed-off-by: Volker Lendecke <vl@samba.org>
2019-11-19 14:15:33 +10:00
Ronnie Sahlberg e4fa3b5bcb make LGTM.com happy and squash a false warning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-09-27 20:48:58 -07:00
Daniel Abrecht b3fd3ca7e4 Move win32/win32_compat.h to include/win32/win32_compat.h 2018-04-16 19:42:38 +00:00
Ronnie Sahlberg dc9669abd5 Fix compiler warnings about cast from char* -> uint32_t*
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 16:33:55 +10:00
Ronnie Sahlberg e27453b4a9 Make valgrind happy for libnfs_zdr_bytes
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 07:56:23 +10:00
Ronnie Sahlberg 2db0878396 Use clock_gettime(CLOCK_MONOTONIC_COARSE) if/when available
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-10 18:11:00 -07:00
Ronnie Sahlberg 2d348242c5 Make zdr_malloc() visible outside of libnfs-zdr.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 6f860fd874 Add ZDR* and void* as arguments to zr_void so that it can be used as a zdrproc_t
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 468424c475 ZDR_ARRAY: remove the check for element-size * num-objects
In zdr_array we can not use the check that num_elements * element_size
will fit inside the remaining bytes in the ZDR buffer.
The reason for this is that IF it is an array of unions, then
element-size will have the size of the largest arm in that union.

If the array consists of union items that are smaller than the largest arm,
then it becomes likely that this will pack in less than num_elements *
element_size and this it is possible that the array WILL fir in the remaining
bytes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-11-25 14:47:00 -08:00
sahlberg dc8e10df07 WIN32: compiler warnings 2016-09-21 10:49:59 -07:00
Ronnie Sahlberg 6cde2aca64 Conditionally include unistd.h from libnfs-zdr.c as some platforms lack this header
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-20 17:36:19 -07:00
Ronnie Sahlberg f9455e5ba5 gcc 5.3 does not allow casting a char * to any longer, so cast via void *
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-02 09:20:54 +02:00
Ronnie Sahlberg a5408bfa09 zdr string decode: don't memcpy when src and dst pointers are the same
If we are decoding a zdr string and the called did not provide
a pointer/buffer for us. We can just return the string to the rx buffer
immediately and avoid calling libnfs_zdr_opaque().

This avoids wasting cpu cycles on running a memcpy where src and dst buffers
are the same.
2016-03-21 22:06:59 -07:00
Ronnie Sahlberg 4476f11b9d Try to avoid allocating memory during zdr string decoding
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:16:35 -08:00
Ronnie Sahlberg 62daa224d9 Remove the zdr_malloc call when decoding a BYTES blob
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:15:20 -08:00
Ronnie Sahlberg e3cf674856 Use a single allocation for zdr_mem and the payload
Lets use a single allocation instead of two in the zdr_mem handler.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:13:47 -08:00
Ronnie Sahlberg 84607f4821 Add -Wall -Werror and friends
Update the configure to add some sanity -W arguments.
A good start is probably :
  -Wall -Werror -Wshadow -Wno-write-strings -Wstrict-prototypes
  -Wpointer-arith -Wcast-align -Wno-strict-aliasing

Fixup the paces in the code that triggers.
(one of which is readahead code which is perhaps broken?)

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-10 21:06:38 -07:00
Ronnie Sahlberg bce63d849c types: remove the [u_]quad type and replace with [u]int64
All current platforms have a quad type that maps to a 64bit scalar.
But there are platforms where quad maps to a 64bit non-scalar.

Replace quad with int64 in the protocol definitions and the ZDR layer
so that these fields will map to a 64 bit scalar also on those platforms
where quad can not be used.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-16 14:51:53 -07:00
Mike Frysinger e48cfe9622 fix implicit decls of rpc_{g,s}et_error
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-08-11 06:08:33 -07:00
Mike Frysinger 10a1a78115 fix implicit decl warnings
Include the proper headers to fix warnings like:
libnfs-sync.c:1529:3: warning: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
libnfs-zdr.c:506:2: warning: implicit declaration of function 'getuid' [-Wimplicit-function-declaration]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

sys/time.h needs to be protected with an ifdef

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-11 06:08:05 -07:00
Ronnie Sahlberg b25c3aedde We only need to spend CPU computing a new error string IFF there was an error
when unmarshalling the reply.
2014-03-12 05:54:38 -07:00
Ronnie Sahlberg f0cb804219 Improve error reporting when unmarshalling of message headers fail. 2014-03-11 18:52:48 -07:00
Peter Lieven 1f3f0d5853 libnfs_zdr_opaque: make valgrind happy
valgrind complains about unitialized memory

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 12:46:31 +01:00
Peter Lieven b554c8e8d2 libnfs_authunix_create: make valgrind happy
valgrind complains about uninitialized memory.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-17 11:47:59 +01:00
Ronnie Sahlberg c81e7d8921 Make sure the the value is unsigned before we OR it into the uint64_t
or else the sign might be extended.
2013-10-20 12:41:56 -07:00
Ronnie Sahlberg 4e019b25b5 On Windows, use 65534/65534 instead of 65535/65535 for the default uid/gid 2013-05-30 17:58:29 -07:00
Ronnie Sahlberg 0556ee05e1 Aros fixes 2013-05-28 22:41:54 -07:00
Ronnie Sahlberg 833d5b9da1 Include ifdef cleanup 2013-05-28 21:20:00 -07:00
Ronnie Sahlberg 67a9f57e67 WIN32 fixes 2013-05-28 16:15:16 -07:00
Ronnie Sahlberg 43e0e7a7e6 On unix systems, when creating the default authentication token
use getgid() as the group instead of -1.
Recent linux knfsd do not allow grp==-1

On windows there are no uid/gids in the traditional sense so there I still specify a default credential of uid==gid==-1 :
	rpc->auth = authunix_create("LibNFS", 65535, 65535, 0, NULL);

This is I think the sanest/safest thing to do since most servers will have
special handing of -1 meaning 'nobody' or similar.
This should work on many/most servers and give the user the minimum available
access allowed for 'nobody'.

I think on windows (or AROS for that matter) applications will probably have
to invoke and set the credentials themself explicitely.
Those apps probably, unfortunately, also need to have a configuration
setting to select which uid/gid to use when talking to the server.
(or they could hardcode it)

rpc_set_auth(rpc, libnfs_authunix_create("hostname", uid, gid, 0, NULL))
should do the trick if they call immediately after creating the rpc/nfs context.

But dont set it to 0,0 root/root for uid/gid.
First of all, most servers have root-squash so they will re-map this uid/gid
to 'nobody' internally.
But, if the user uses a server that does not do root-squash, then setting this to 0,0 would mean that your app now access the nfs share as root   which is probably not what you want.
2013-05-25 06:24:15 -07:00
Ronnie Sahlberg d7c6e9aaa9 Initial AROS support.
The test app doesnt link yet since we are missing a bunch of symbols

but it is a start
2013-04-10 20:28:40 -07:00
Ronnie Sahlberg aab6538bbd Implement 'rejected_reply' and switch to RFC5531 definitions
Switch to using fields and names from RFC5531. that is the standard
for RPC.
2012-11-26 19:42:10 -08:00
Ronnie Sahlberg 5f08d03e16 ZDR_ARRAYS: The sub-unmarshaller returns TRUE FALSE if there was an error, not TRUE 2012-11-24 09:01:00 -08:00
Ronnie Sahlberg b14062764e ZDR: we need to include both arpa/inet.h and time.h 2012-07-05 21:17:45 +10:00
Ronnie Sahlberg 442b829a05 Dont just cast *enum_t to *uint32_t
go via a temporary variable in case these scalars are different size
2012-07-05 21:13:04 +10:00
Ronnie Sahlberg 67ba2239cb Get rid of AUTH completely and replace all uses with 'struct AUTH' 2012-07-05 10:23:19 +10:00
Ronnie Sahlberg 45670bd0d6 fix compiler warnings 2012-07-05 07:37:37 +10:00
Ronnie Sahlberg 020f172895 fix compiler warning 2012-07-05 07:35:04 +10:00
Ronnie Sahlberg 10a0ceaaa3 librpc_rpc_call_body() should return TRUE is successful 2012-07-05 07:09:00 +10:00
Ronnie Sahlberg 242b81cfbf setpos returns a boolean, set it to always return TRUE 2012-07-05 07:06:33 +10:00
Ronnie Sahlberg 763cd6e3e2 ZDR: New builtin replacement for RPC/XDR called ZDR
This patch switches libnfs over to use precompiled rpcgen files
and using ZDR.  ZDR is a trivial reimplementation of XDR that is built in
into libnfs.

This removes the dependencies of rpc/xdr completely and allow us to build on any
system, even systems where rpcgen and librpc/libxdr are not generally available.
2012-07-04 16:53:12 +10:00