Commit Graph

493 Commits (aec45c6274bffc92fc1595a95d043e8aae292451)

Author SHA1 Message Date
Arne Redlich 8907aea9eb socket.c: fix format string issues (too few arguments)
These were uncovered by the previously added __attribute__((format(printf))).

Emacs also removed trailing whitespace while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:59:17 -08:00
Arne Redlich 8406bfe465 {nfs,rpc}_set_error: add __attribute__((format(printf))) annotations
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:58:48 -08:00
Arne Redlich 766bb4af75 nfs_rename_continue_1_internal: fix use-after-free
Spotted by clang analyzer.
This introduces another allocation to create a copy of the target path
of a rename in case it needs to be reported via rpc_set_error - it might
be a better idea to avoid the allocation and have a slightly less informative
error message?

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:58:02 -08:00
Arne Redlich bcbb21cdbb nfs_unlink_async: plug potential memory leak
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:57:28 -08:00
Arne Redlich 2257433dd4 nfs_rmdir_async: fix potential memory leak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:55:42 -08:00
Arne Redlich b1a197f5b2 nfs_mkdir_async: fix potential memory leak
Pointed out by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:55:22 -08:00
Arne Redlich ecc656491a nfs_mknod_async: fix use-after-free
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:54:58 -08:00
Arne Redlich b41762c0d8 nfs_fchown_async: fix use-after-free
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:54:37 -08:00
Arne Redlich faa15589f1 nfs_fchmod_async: fix use-after-free
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:53:22 -08:00
Arne Redlich a26bebefce nfs_opendir2_cb: plug potential memleaks
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:52:34 -08:00
Arne Redlich 2fa14f9b97 free_nfs_cb_data: make static and drop superfluous nullptr checks / assignments
free() can cope with nullptrs and there's no point in null-ing free'd members
as the containing struct is free'd as well.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:52:05 -08:00
Arne Redlich 206a2ff644 free_nfs_cb_data: add assert(data->free_continue_data)
Non-debug builds will trip over the nullptr too - do we rather
want to leak the memory there?

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:50:09 -08:00
Arne Redlich 6b1f14ca01 nfs_fchown_async: fix nullptr dereference
nfs_chown_data is hooked up under nfs_cb_data->continue_data but
no ->free_continue_data is configured, so once free_nfs_cb_data is
invoked it will trip over a nullptr.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:49:03 -08:00
Arne Redlich b6619d88e6 nfs_fchown_async: plug potential memleak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:47:50 -08:00
Arne Redlich a128749648 nfs_creat_async: plug potential memleak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:47:27 -08:00
Arne Redlich feb2fc2f92 nfs_mknod_async: plug potential memory leak
Pointed out by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:47:02 -08:00
Arne Redlich e59193c9f9 nfs_lookuppath_async: plug potential memleak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:46:09 -08:00
Arne Redlich b2fc5c54d9 nfs_opendir_cb: plug potential memory leak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:45:33 -08:00
Arne Redlich e94d5a7d51 libnfs-raw.h: rename export -> exportname to avoid clash with C++ keyword
From http://en.cppreference.com/w/cpp/keyword/export :

  Until C++11:
  "Used to mark a template definition exported, which allows the same
   template to be declared, but not defined, in other translation units."

  Since C++11:
  "The keyword is unused and reserved."

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:43:16 -08:00
Arne Redlich d48be00c5e libnfs.h: wrap in extern "C" for C++ compatibility
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:42:03 -08:00
Arne Redlich 4b1ae88abb nfs_normalize_path: fix using the results of assignments in while loops
Spotted by clang:
 ../../libnfs.git/lib/libnfs.c:1002:13: warning: using the result of an assignment as a condition without parentheses
       [-Wparentheses]
         while (str = strstr(path, "//")) {
                ~~~~^~~~~~~~~~~~~~~~~~~~
 ../../libnfs.git/lib/libnfs.c:1002:13: note: place parentheses around the assignment to silence this warning
         while (str = strstr(path, "//")) {
                    ^
                (                       )
 ../../libnfs.git/lib/libnfs.c:1002:13: note: use '==' to turn this assignment into an equality comparison
         while (str = strstr(path, "//")) {
                    ^
                    ==

Make the intent clear by adding extra parentheses, and also
remove trailing whitespace from libnfs.c while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:41:34 -08:00
Arne Redlich a81c5ea1d2 libnfs-zdr.h: wrap in extern "C" for C++ compatibility
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:40:30 -08:00
Arne Redlich 4641d36ef4 libnfs-raw.h: wrap in extern "C" for C++ compatibility
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:40:11 -08:00
Arne Redlich 324234ee10 libnfs-private.h: wrap in extern "C" for C++ compatibility
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:39:52 -08:00
Arne Redlich 17876230a9 slist.h: add include guards
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:39:28 -08:00
Arne Redlich 83a446dd8d libnfs-private.h: add include guards
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:38:59 -08:00
Arne Redlich 3751901fc4 libnfs-raw.h: remove trailing whitespace
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:38:34 -08:00
Arne Redlich 52014ebf37 libnfs.h: add include guards
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:37:59 -08:00
Ronnie Sahlberg d84d168f0f Change license for the ld preload hack to gplv3 2014-02-11 18:36:24 -08:00
Ronnie Sahlberg b8c28d541e Add a simple LD_PRELOAD toy to make cat and cp nfs-aware 2014-02-02 18:03:50 -08:00
Ronnie Sahlberg be7b4360ac We need to pass a filehandle back for open(O_TRUNC) or else the app will
be unhappy
2014-02-02 17:39:04 -08:00
Ronnie Sahlberg 22a0f15bee Add support for O_TRUNC with nfs_open()
O_TRUNC will attempt to truncate the file when opened with O_RDWR
or O_WRONLY.

Normal posix open(O_RDONLY|O_TRUNC) is undefined.

libnfs nfs_open() only uses the O_TRUNC flag when used in combination with either O_RDWR or O_WRONLY.
When O_TRUNC is used together with O_RDONLY libnfs will silently ignore the O_TRUNC flag.

Libnfs nfs_open(O_RDONLY|O_TRUNC) is thus the same as nfs_open(O_RDONLY)
2014-02-02 12:16:07 -08:00
Ronnie Sahlberg 3cea44dc54 Rename the nfs_open() argument from mode to flags 2014-02-02 11:41:22 -08:00
Ronnie Sahlberg 6ec481d3fa Add a rpc_set_fd() fucntion which can be used to swap the underlying socket file descriptor
This is mainly needed when having to track and control the file descriptors that are used by libnfs, for example when trying to emulate dup2() ontop
of libnfs.
2014-02-02 08:45:21 -08:00
Ronnie Sahlberg 34edf264dc Empty paths are no longer an error. Translate it to '.' instead. 2014-02-01 08:03:12 -08:00
Ronnie Sahlberg f893b680f2 Add support for chdir and getcwd
Add chdir and getcwd and store cwd in the nfs_context.
Add functions to process the paths specified and normalize them
by performing the transforms :
    // -> /
    /./ -> /
    ^/../ -> error
    ^[^/] -> error
    /string/../ -> /
    /$ -> \0
    /.$ -> \0
    ^/..$ -> error
    /string/..$ -> /

Update the path lookup function to allow specifying relative paths based on
cwd for all functions.
2014-01-30 20:06:57 -08:00
Ronnie Sahlberg 0a63cc7258 Remove chdir changes for now. Needs more testing. 2014-01-30 18:30:25 -08:00
Ronnie Sahlberg 0df47959c4 Revert "Add support for chdir and getcwd"
This reverts commit fb6f315257.
2014-01-30 18:26:39 -08:00
Ronnie Sahlberg 1d95217b2f New version 1.9.1
Add back the libnfs-raw-*.h headers to make install
2014-01-28 06:41:31 -08:00
Ronnie Sahlberg bcb4f1bd1c We need the libnfs-raw-*.h files in include/Makefile.am
or else the autotools (which I dont really understand how it works)
will not install the headers.
2014-01-28 06:35:52 -08:00
Ronnie Sahlberg fb6f315257 Add support for chdir and getcwd
Add chdir and getcwd and store cwd in the nfs_context.
Add functions to process the paths specified and normalize them
by performing the transforms :
    // -> /
    /./ -> /
    ^/../ -> error
    ^[^/] -> error
    /string/../ -> /
    /$ -> \0
    /.$ -> \0
    ^/..$ -> error
    /string/..$ -> /

Update the path lookup function to allow specifying relative paths based on
cwd for all functions.
2014-01-27 20:54:59 -08:00
Ronnie Sahlberg 5392b1cfbc New version : 1.9.0
- Use _stat64 on windows so file sizes become 64bit always.
 - Increase default marshalling buffer so we can marshall large PDUs.
 - RPC layer support for NFSv2
 - Win32 updates and fixes
 - Add URL parsing functions and URL argument support.
 - New utility: nfs-io
 - nfs-ls enhancements
 - RPC layer support for NSM
 - Add example FUSE filesystem.
 - Minor fixes.
2014-01-27 20:47:24 -08:00
Ronnie Sahlberg 37e3eace2a Merge pull request #50 from asgeirn/master
Fixed SPEC file to work with Red Hat 6.3 x64.
2014-01-16 06:25:35 -08:00
Asgeir Storesund Nilsen 9304ad516e Fixed SPEC file to work with Red Hat 6.3 x64. 2014-01-16 10:03:14 +00:00
Ronnie Sahlberg f537d520d1 Merge pull request #49 from Memphiz/win32fix4
Win32fix4
2014-01-13 18:14:19 -08:00
Memphiz e6a8481ffd [win32] - fix comilation by removing a unused "int i;" - though i have no
clue why this fails with "';' missing before 'Typ'"
2014-01-13 19:52:58 +01:00
Memphiz 18bfd0b2a2 [win32] - add new missing files to vs project 2014-01-13 19:52:06 +01:00
Memphiz 4938ed42f3 [win32/nlm] - add missing typedef for u_quad_t and quad_t 2014-01-13 19:50:59 +01:00
Ronnie Sahlberg ecbd14a153 Make sure cookie is initialized before we use it. 2014-01-13 06:36:38 -08:00
Ronnie Sahlberg 9180287b27 Export the three new nfs_set_* functions from the windows library/dll 2014-01-13 06:30:43 -08:00