summaryrefslogtreecommitdiff
path: root/source3/lib/util_file.c
AgeCommit message (Collapse)AuthorFilesLines
2025-08-15lib: Move file_lines_ploadv() to lib/util/Volker Lendecke1-24/+0
Make it available to ctdb Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-08-15lib: Fix memory leak CID#1469247Vinit Agnihotri1-1/+4
pointer 'p' gets duplicated in file_lines_parse(), but not free'd before returning. Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Aug 15 08:53:53 UTC 2025 on atb-devel-224
2024-04-16lib: Give lib/util/util_file.c its own header fileVolker Lendecke1-1/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2021-03-09lib: Fix file_ploadv_send/recv cleanupVolker Lendecke1-14/+21
We have to first TALLOC_FREE() the waiting event before closing the pipe. Otherwise EPOLL_CTL_DEL is unhappy and might remove an unrelated file descriptor. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28lib: Fix file_ploadv_send()/_recv()Volker Lendecke1-0/+7
When reading more than 1024 bytes, don't insert '\0' bytes in between those chunks. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Samuel Cabrero <scabrero@samba.org>
2019-05-24s3: lib: Rename all uses of file_pload_XXX -> file_ploadv_XXX.Ralph Boehme1-15/+15
Keep naming consistent across all usage. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-05-24s3: lib: Remove file_pload_send().Jeremy Allison1-29/+0
No longer used. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-05-24s3: lib: Add file_ploadv_send().Jeremy Allison1-0/+29
Not yet used. Preparing to remove file_pload_send() with this safer alternative. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-05-24s3: lib: Remove file_lines_pload().Jeremy Allison1-14/+0
No longer used. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-05-24s3: lib: util: Add file_lines_ploadv().Jeremy Allison1-0/+15
Not yet used. Duplicate code to file_lines_pload() except uses vectored argument list. file_lines_pload() will be removed once all callers are converted. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-02-11s3:util: Move static file_pload() function to lib/utilAliaksei Karaliou1-47/+0
file_pload() is static private function in Samba3 library, however it does not have any special dependencies and might be widely used as common function, so moving it into common samba-util library. Signed-off-by: Aliaksei Karaliou <akaraliou@panasas.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-11s3:util: Move popen wrappers to lib/utilAliaksei Karaliou1-1/+1
When linked into Samba3 libraries, sys_popen()/sys_pclose() cannot be used in lower level libraries because of circular dependencies. This patch moves them into common samba-util library. Signed-off-by: Aliaksei Karaliou <akaraliou@panasas.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-02-23lib: Remove "includes.h" from util_file.cVolker Lendecke1-1/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-02-23lib: Add file_pload_send/recvVolker Lendecke1-0/+127
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-02-23lib: Add "mem_ctx" to file_lines_ploadVolker Lendecke1-2/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-02-23lib: Extract sys_popen()Volker Lendecke1-0/+1
This was added by Jeremy with 3cf31a194f5, do the (C) accordingly sys_popen is a pretty isolated functionality, and I'd like to use it soon without "includes.h", needed by "proto.h" Except for one malloc->talloc this is supposed to be a 1:1 copy Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-02-23lib: Fix whitespaceVolker Lendecke1-3/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2015-10-13lib: Move sys_rw* to lib/utilVolker Lendecke1-1/+1
genrand.c will require it soon Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-26Fix a comment to indicate that TALLOC_FREE must be used to free an allocated ↵Richard Sharpe1-1/+1
array of strings. Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Dec 26 22:54:51 CET 2014 on sn-devel-104
2014-12-07lib: Split out sys_[read|write] & friendsVolker Lendecke1-0/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-01-24Fix bug #9586 - smbd[29175]: disk_free: sys_popen() failed" message logged ↵Jeremy Allison1-1/+1
in /var/log/message many times. Ensure when reading lines from an interruptible pipe source we ignore EINTR. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jan 24 10:45:48 CET 2013 on sn-devel-104
2009-03-26Fix a talloc/malloc screwup in file_lines_ploadVolker Lendecke1-1/+1
Another bug due to careless merge to /lib :-((( Volker
2008-10-12Use common util_file code.Jelmer Vernooij1-345/+7
2007-11-15More pstring removal. This one was tricky. I had to addJeremy Allison1-2/+2
one horror (pstring_clean_name()) which will have to remain until I've removed all pstrings from the client code. Jeremy. (This used to be commit 1ea3ac80146b83c2522b69e7747c823366a2b47d)
2007-10-18RIP BOOL. Convert BOOL -> bool. I found a few interestingJeremy Allison1-3/+3
bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f)
2007-10-10r23801: The FSF has moved around a lot. This fixes their Mass Ave address.Andrew Tridgell1-2/+1
(This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227)
2007-10-10r23779: Change from v2 or later to v3 or later.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3)
2007-10-10r23659: file_pload is not used outside of util_file.cVolker Lendecke1-1/+1
(This used to be commit 3ec43e18a4ffc46700de484251ea0bb2a18cde78)
2007-10-10r20179: Sync up with Samba4 - remove blank lines at theJeremy Allison1-3/+9
end parsing a file. Jeremy. (This used to be commit ea8215935e5f3952a4480c1f7dafafa9458f66a9)
2007-10-10r17592: Remove some unused functions pointed out by John E. Malmberg, makeVolker Lendecke1-235/+0
do_file_lock static to pdb_smbpasswd.c, the only user of it. Volker (This used to be commit 543f77a45f0a75ede48b0f2c674a0abdd386fed5)
2007-10-10r17316: More C++ warnings -- 456 leftVolker Lendecke1-1/+1
(This used to be commit 1e4ee728df7eeafc1b4d533240acb032f73b4f5c)
2007-10-10r15005: Fix printf args to remove warnings.Jeremy Allison1-3/+3
Jeremy. (This used to be commit 68d100830c5a6fa24b863071e8ca77ab264175a0)
2007-10-10r15003: patch based on code from Arkady Glabek <aglabek@centeris.com> to ↵Gerald Carter1-0/+20
ensure that global memory is freed when unloading pam_winbind.so (needs more testing on non-linux platforms) (This used to be commit 1e0b79e591d70352a96e0a0487d8f394dc7b36ba)
2007-10-10r13915: Fixed a very interesting class of realloc() bugs found by Coverity.Jeremy Allison1-14/+9
realloc can return NULL in one of two cases - (1) the realloc failed, (2) realloc succeeded but the new size requested was zero, in which case this is identical to a free() call. The error paths dealing with these two cases should be different, but mostly weren't. Secondly the standard idiom for dealing with realloc when you know the new size is non-zero is the following : tmp = realloc(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } However, there were *many* *many* places in Samba where we were using the old (broken) idiom of : p = realloc(p, size) if (!p) { return error; } which will leak the memory pointed to by p on realloc fail. This commit (hopefully) fixes all these cases by moving to a standard idiom of : p = SMB_REALLOC(p, size) if (!p) { return error; } Where if the realloc returns null due to the realloc failing or size == 0 we *guarentee* that the storage pointed to by p has been freed. This allows me to remove a lot of code that was dealing with the standard (more verbose) method that required a tmp pointer. This is almost always what you want. When a realloc fails you never usually want the old memory, you want to free it and get into your error processing asap. For the 11 remaining cases where we really do need to keep the old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR, which can be used as follows : tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the pointer p, even on size == 0 or realloc fail. All this is done by a hidden extra argument to Realloc(), BOOL free_old_on_error which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR macros (and their array counterparts). It remains to be seen what this will do to our Coverity bug count :-). Jeremy. (This used to be commit 1d710d06a214f3f1740e80e0bffd6aab44aac2b0)
2007-10-10r13316: Let the carnage begin....Gerald Carter1-13/+20
Sync with trunk as off r13315 (This used to be commit 17e63ac4ed8325c0d44fe62b2442449f3298559f)
2007-10-10r12043: It's amazing the warnings you find when compiling on a 64-bitJeremy Allison1-1/+1
box with gcc4 and -O6... Fix a bunch of C99 dereferencing type-punned pointer will break strict-aliasing rules errors. Also added prs_int32 (not uint32...) as it's needed in one place. Find places where prs_uint32 was being used to marshall/unmarshall a time_t (a big no no on 64-bits). More warning fixes to come. Thanks to Volker for nudging me to compile like this. Jeremy. (This used to be commit c65b752604f8f58abc4e7ae8514dc2c7f086271c)
2007-10-10r4088: Get medieval on our ass about malloc.... :-). Take control of all our ↵Jeremy Allison1-5/+5
allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a)
2007-10-10r2155: Reformat, plus steal from Samba4 :-).Jeremy Allison1-233/+259
tridge: the lp_use_mmap() in map_file() is inappropriate for 2 reasons, so I have removed it. - lp_use_mmap() is really meant to cope with systems that have broken mmap coherence, but map_file() doesn't need coherence, as its maps read only - map_file() is used to map the charset files before loadparm has loaded, so lp_use_mmap() is always returning false for the major use of map_file() Jeremy. (This used to be commit 3716dbc0cb9a8ca4027217b24dbf62a62f44e9f6)
2003-09-08fix compile error on HP-UX 10.20Gerald Carter1-0/+5
(This used to be commit 15d53fd53c622de316d0ff41f1b60f0e2c69f908)
2003-07-25More printf portability fixes. Got caught out by some gcc'isms lastTim Potter1-2/+2
time. )-: (This used to be commit 59dae1da66a5eb7e128263bd578f167d8746e9f0)
2003-07-24More printf fixes - size_t is long on some architectures.Tim Potter1-1/+1
(This used to be commit ba4d334b822248d8ab929c9568533431603d967e)
2003-02-24Merge doxygen, signed/unsigned, const and other small fixes from HEAD to 3.0.Andrew Bartlett1-2/+5
Andrew Bartlett (This used to be commit 9ef0d40c3f8aef52ab321dc065264c42065bc876)
2002-07-15updated the 3.0 branch from the head branch - ready for alpha18Andrew Tridgell1-3/+6
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)
2002-03-26Don't hold the mutex for more than 20 seconds.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 1b9f1a368f2f37700cef357ab4bbc0389ec06378)
2002-03-15lower the debug level of failing to map a fileAndrew Tridgell1-1/+1
(This used to be commit ad9965414d4d1fd8a031e3169b8f19d66cdad8be)
2002-01-30Removed version number from file header.Tim Potter1-1/+2
Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa)
2001-12-17obey "use mmap" on case tablesAndrew Tridgell1-11/+13
(This used to be commit 505a1bdd15313698a6024a847f3771ea30a51f89)
2001-10-11initial kerberos/ADS/SPNEGO support in libsmb and smbclient. ToAndrew Tridgell1-0/+17
activate you need to: - install krb5 libraries - run configure - build smbclient - run kinit to get a TGT - run smbclient with the -k option to choose kerberos auth (This used to be commit d33057585644e1337bac743e25ed7653bfb39eef)
2001-10-03switched over to a new method of handling uppercase/lowercase mappingsAndrew Tridgell1-0/+35
for unicode strings. The new method relies on 3 files that are mmap'd at startup to provide the mapping tables. The upcase.dat and lowcase.dat tables should be the same on all systems. The valid.dat table says what characters are valid in 8.3 names, and differs between systems. I'm committing the japanese valid.dat here, in future we need some way of automatically installing and choosing a appropriate table. This commit also adds my mini tdb based gettext replacement in intl/lang_tdb.c. I have not enabled this yet and have not removed the old gettext code as the new code is still being looked at by Monyo. Right now the code assumes that the upcase.dat, lowcase.dat and valid.dat files are installed in the Samba lib directory. That is not a good choice, but I'll leave them there until we work out the new install directory structure for Samba 3.0. simo - please look at the isvalid_w() function and think about using it in your new mangling code. That should be the final step to correctly passing the chargen test code from monyo. (This used to be commit 1c221994f118dd542a158b2db51e07d04d0e9314)
2001-10-02Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header.Tim Potter1-2/+0
(This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e)