summaryrefslogtreecommitdiff
path: root/lib/util/util_file.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-17lib: Optimize file_compareVolker Lendecke1-14/+41
Triggered by two coverity false positives. Loading both files into talloc'ed memory seems inefficient to me. Rely on stdio to do proper buffering. This removes the restriction from ae95d611: "It is meant for small files". This is more lines, but to me it has less implicit complexity. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org> Autobuild-User(master): Uri Simchoni <uri@samba.org> Autobuild-Date(master): Wed Jul 17 12:45:51 UTC 2019 on sn-devel-184
2019-07-01util: Fix signed/unsigned comparisons by castingMartin Schwenke1-2/+4
One case needs a variable declared, so it can be compared to -1 and then cast to size_t for comparison. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Jul 1 08:00:29 UTC 2019 on sn-devel-184
2019-07-01util: Fix signed/unsigned comparisons by declaring as size_tMartin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-05-24lib: util: Remove file_pload()Jeremy Allison1-46/+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-24lib: util: Add file_ploadv().Jeremy Allison1-0/+46
Not yet used. Duplicate code to file_pload() except uses vectored argument list. file_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-03-26lib: Make fd_load work for non-regular filesVolker Lendecke1-15/+48
Follow-up to https://lists.samba.org/archive/samba/2018-September/217992.html and following. This also fixes a small and very theoretical race: Between the fstat and the read call the file size might change. This would make us fail on potentially legitimate files. This is more complex and probably slower, but looking at the use cases I don't think the speed matters. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13859 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Mar 26 04:43:40 UTC 2019 on sn-devel-144
2019-02-11s3:util: Move static file_pload() function to lib/utilAliaksei Karaliou1-0/+48
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>
2018-12-19lib/util: Count a trailing line that doesn't end in a newlineMartin Schwenke1-3/+3
If the final line of a file does not contain a newline then it isn't included in the line count. Change i to point to the next slot in the array instead of the current one. This means that that the current line won't be thrown away if no newline is seen. Without changing i to unsigned int, the -O3 --picky -developer build fails with: [ 745/4136] Compiling lib/util/util_file.c ==> /builds/samba-team/devel/samba/samba-o3.stderr <== ../../lib/util/util_file.c: In function ‘file_lines_parse’: ../../lib/util/util_file.c:251:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] while (i > 0 && ret[i-1][0] == 0) { ^ cc1: all warnings being treated as errors BUG: https://bugzilla.samba.org/show_bug.cgi?id=13717 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Dec 19 08:08:28 CET 2018 on sn-devel-144
2018-04-03lib:util: Fix size types in fgets_slash()Andreas Schneider1-2/+2
This fixes compilation with -Wstrict-overflow=2. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-03-01lib:util: Add FALL_THROUGH statements in util_file.cAndreas Schneider1-1/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-11lib: Add fgets_slashVolker Lendecke1-0/+82
Copy x_fgets_slash with conversion to stdio and talloc. Probably I'd do this functionality a bit differently, but for simplicity I chose to make it the same as what is there. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-11-20lib: Move x_fgets_slash to xfile.cVolker Lendecke1-92/+0
This makes it easier to remove the global #include xfile.h Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-11-20lib: Apply an overflow checkVolker Lendecke1-3/+11
Very unlikely here, as the realloc will have failed long before, but still I would like to check overflow. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-11-20lib: Reformat x_fgets_slashVolker Lendecke1-64/+68
This is so old code that I'd like to move somewhere else next, but before that I'd like to clean it up a bit. No code change, just indentation changed and some {} added. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-11-20lib: Rename fgets_slash to x_fgets_slashVolker Lendecke1-2/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2015-03-24lib: Remove unused [un]map_fileVolker Lendecke1-56/+0
Reviewed-by: Jeremy Allison <jra@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org>
2014-12-27lib: Use talloc_zero_array instead of memsetVolker Lendecke1-3/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Sat Dec 27 01:27:08 CET 2014 on sn-devel-104
2014-12-09lib: Fix blank line endingsVolker Lendecke1-13/+13
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-17lib: Remove unused file_lines_slashcontVolker Lendecke1-24/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-17lib: Move "large_file_support()" to the source4 smb serverVolker Lendecke1-21/+0
That's the only place where it's used, make it static there. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-11-11CVE-2013-4476: lib-util: split out file_save_mode() from file_save()Björn Baumbach1-5/+11
file_save_mode() writes files with specified mode. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10234 Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2011-10-22lib/util: remove the "includes.h" dependeny from util_file.cStefan Metzmacher1-5/+4
metze
2010-10-20s3: Don't use talloc_autofree_context in map_fileVolker Lendecke1-1/+1
2010-02-11util: added file_compare() utility functionAndrew Tridgell1-0/+22
file_compare() returns true if two files are the same. It is meant for small files. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2009-07-19lib/util/util_file.c(file_save): fixed file descriptor leak when read(2) fails.Slava Semushin1-0/+1
Found by cppcheck: [./lib/util/util_file.c:383]: (error) Resource leak: fd
2008-10-18Use the new memory macro file from Samba 3.Jelmer Vernooij1-1/+0
2008-10-12Use common util_file code.Jelmer Vernooij1-13/+46
2008-10-11Move lib/util from source4 to top-level libutil.Jelmer Vernooij1-0/+404
Conflicts: source4/Makefile