summaryrefslogtreecommitdiff
path: root/source3/lib/util_file.c
AgeCommit message (Collapse)AuthorFilesLines
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)
2001-09-29Add a few const statements to various odd bits of the tree. (Fixes someAndrew Bartlett1-2/+2
warnings) (This used to be commit b648cc669d16eb40b477c8dc51efeab485a15de5)
2001-09-17move to SAFE_FREE()Simo Sorce1-7/+7
(This used to be commit 60e907b7e8e1c008463a88ed2b076344278986ef)
2001-09-10convert more code to use XFILEAndrew Tridgell1-3/+3
(This used to be commit fe6679dffba9a92bb35933ad52172c9be0e9ef90)
2001-08-12this is a big global fix for the ptr = Realloc(ptr, size) bug.Simo Sorce1-7/+15
many possible mem leaks, and segfaults fixed. someone should port this fix to 2.2 also. (This used to be commit fa8e55b8b465114ce209344965c1ca0333b84db9)
2001-08-05Some fixes about malloc/Realloc and mem leakSimo Sorce1-1/+3
thanks to andreas moroder (This used to be commit b29a549cdd85d42a1697041ab04f0ae4eddd23ca)
2001-07-04strchr and strrchr are macros when compiling with optimisation in gcc, so we ↵Andrew Tridgell1-1/+1
can't redefine them. damn. (This used to be commit c41fc06376d1a2b83690612304e85010b5e5f3cf)
2001-07-04The big character set handling changeover!Andrew Tridgell1-16/+9
This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a)
2001-04-13As Andrew suggested, make smbrun return a fd for a deleted file which can thenJeremy Allison1-12/+40
be read. Jeremy. (This used to be commit e7d59d6de89a5fdd201e4b5c6072dab08b1519db)
2000-12-09Fixed typo causing coredump in file_lines_parse.Jeremy Allison1-1/+1
Jeremy. (This used to be commit f575f4d67a5b45e47c29de30f02901c55cef4621)
2000-12-07file_lines_load/file_lines_pload can now optionally convert unix_to_dos()Jeremy Allison1-7/+14
on read. Jeremy. (This used to be commit 76b8dd376d13eb4469417be217c966d54d333367)
2000-12-01Allow zero length smb.conf files.Tim Potter1-2/+0
(This used to be commit 46007a541cd2497c14659a10ba24a6d0a375ac5a)
2000-08-18oops. must return "" string and length zero when strlen(filebuf) == 0Luke Leighton1-13/+16
(This used to be commit d3bc7cca99e47ce89035a03022d7c3ec69e01636)
2000-08-18getfileline() - line with length of zero -> filebuf[strlen(filebuf)-1]Luke Leighton1-10/+13
is NOT ok. (This used to be commit 24e0c8ef70dc59bfaaa113c3d44befbccbcba15f)
2000-04-30 - added some error checkingAndrew Tridgell1-1/+1
- removed the VTP hook in smbd (This used to be commit 09355fcd50e6c9c0c81e5f70ab9b7ff88aa897bf)
2000-04-18fixed some crash bugs in the nt forms parsingAndrew Tridgell1-0/+2
(This used to be commit e505a6ddf3df37ca485cae117c53fa96d736f897)
2000-04-16converted a couple more functions to use a fd instead of a FILE*Andrew Tridgell1-0/+23
added a new utility fn file_lines_slashcont() which is used to handle files that treat a \ followed by a newline as a blank (This used to be commit 384ecd9d66ccd31ee85000c0ca55d413d8f2cc53)
2000-04-16converted a bunch more functions to use a fd instead of a FILE*Andrew Tridgell1-11/+91
to support some of this I added the following functions in util_file.c file_lines_pload : load lines from a pipe file_pload : load a pipe into memory (This used to be commit a09470817c5b21dba42f9ef4ce5e8b768a254c0b)
2000-04-16added fdprintf()Andrew Tridgell1-2/+4
this is like fprintf() but operates on a file descriptor combined with file_load_lines() this makes it really easy to get rid of the use of fopen() in Samba. (This used to be commit bd5cd502bf52164b95d7bfc026189e04988171db)
2000-04-16the new file_lines_load() and file_lines_free() routines. Very useful!Andrew Tridgell1-0/+64
------------ The following series of commits are for the new tdb based printing backend. This completely replaces our old printing backend. Major changes include: - all print ops are now done in printing/*.c rather than scattered all over the place - system job ids are decoupled from SMB job ids - the lpq parsers don't need to be nearly so smart, they only need to parse the filename, the status and system job id - we can store lots more info about a job, including the full job name - the queue cache control is much better I also added a new utility routine file_lines_load() that loads a text file and parses it into lines. This is used in out lpq parsing and I also want to use it to replace all of our fgets() based code in other places. (This used to be commit be1e98b3f7a6007d2c9ac8e079724cb264e0dd3a)
1999-12-13first pass at updating head branch to be to be the same as the SAMBA_2_0 branchAndrew Tridgell1-54/+16
(This used to be commit 453a822a76780063dff23526c35408866d0c0154)
1999-07-26Jean-Francois spotted bug in use of file_modified() routine submittedLuke Leighton1-1/+1
recently. (This used to be commit 717af2d55d4f964c0449a1e502b6e77d1c3f3f30)