Commit Graph

84 Commits

Author SHA1 Message Date
Vincent Torri 4916973a60 efl: remove inclusion of dirent.h where it is not used
Test Plan: compilation

Reviewers: cedric

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5733

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2018-01-12 11:06:12 -08:00
Al Poole a538f47854 eina_file: make sure we use a stringshare when virtualized.
As the filename is now a stringshare, also make sure virtual
files use stringshares for the filename! Also when unmapping
we still need to test whether it is copied or not as unmap
will break on less tolerant architectures.

@fix T6449
2017-11-30 13:57:25 +00:00
Cedric Bail 6e64a104a6 eina: use a stringshare to store the filename internally.
T6164
2017-10-17 16:15:19 -07:00
Cedric BAIL 674a75ca8b eina: continue to check for magic. 2017-10-05 09:28:13 -07:00
Cedric Bail 4ccc5d4f68 eina: allow eina_file_close(NULL) to simplify code using Eina_File. 2017-10-04 20:56:15 -07:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05:00
Carsten Haitzler 15cdd9b71b eina file - use recursive locks for cache and file to avoid deadlock
since we have a sigbusd handler that flags an eina file with io errors
it has to walk the file cache and every file... taking locks. if those
locks were taking already in the current thread the sighandler was
called in... we'd deadlock. since this basicallly never happens (when
do we see i/o errors really? not much)... we never saw this as it'd
also reauire this race condition to happen too. but it is a problem
waiting to happen. this fixes that by moving to recrusive locks.

@fix
2017-08-30 11:31:02 +09:00
Al Poole 9aeaef55c4 eina_file: fix unmap of unmapped region when Eina_File has copied data and not a map;
Summary:
This was causing problems on non-Linux architectures as eina_file_real_close unmapped not mapped data. Added a "copied" flag to Eina_File which is set on eina_file_virtualize (on copied data), and tested for when eina_file_real_close does the unmap. I'm surprised Linux allowed this. Certainly all of the BSDs crashed with the previous behaviour.

@fix T5479

Test Plan: Example inlcude Rage and Enlightenment Thumb on BSD systems which use eina_file_virtualize with emotion to obtain album artwork.

Reviewers: raster, cedric, jpeg

Reviewed By: jpeg

Maniphest Tasks: T5479

Differential Revision: https://phab.enlightenment.org/D5006
2017-07-07 13:22:53 +09:00
Carsten Haitzler eeb1eb1b74 eina - fix eina_file_virtualize to copy data to an aligned addr
so we copy data to an UNALINED memory address (just after whatever
string we packed on the end of the eina file struct header). this is
bad. especially for non-intel architectures. this forces a 16 byte
alignment which should cover us.

@fix
2017-07-07 12:08:01 +09:00
Jean-Philippe Andre daf87093f8 eina file: Fix rare crash in line iteration
I'm not sure about the rest of this code, so it's possible that
the index is increased even if it shouldn't. But I've observed
a crash at this line, apparently when reaching the end pointer.
2017-07-03 16:23:40 +09:00
Cedric BAIL 9d8549f7a3 eina: add an API to correctly do close on exec. 2017-04-18 16:53:26 -07:00
Cedric Bail 4766316935 eina: force copy of not copied virtualized file while doing an eina_file_dup.
The other way around is pretty much impossible as you don't know who does
an eina_file_dup and for how long they keep there reference.

T5234
2017-03-08 12:24:41 -08:00
Ivan Furs 8a10ef10cb eina_file: delete handle->fm(handel of function CreateFileMapping)
Summary: CreateFileMapping return handle. The handle before use is always closed. This handle can be immediately closed after use.

Reviewers: cedric, raster, vtorri, rimmed, an.kroitor, FurryMyad, NikaWhite

Reviewed By: raster

Subscribers: artem.popov, cedric, jpeg

Tags: #windows

Differential Revision: https://phab.enlightenment.org/D4699
2017-03-06 19:18:46 +09:00
Jean-Philippe Andre 509cce5e43 eina: Set magic number in eina_file_virtualize
This fixes make check
2016-12-09 11:08:38 +09:00
Jean-Philippe Andre f1d546df5d eina: Set magic type name for Eina_File 2016-12-08 16:30:34 +09:00
Jean-Philippe Andre 208e152baf eina: Reinstall magic checks on Eina_File
file != NULL does not mean it's valid. Since Eina_File is
a basic eina type a magic check is still better than nothing.
It can avoid doing eina_file_dup() on a closed file for instance.

This "fixes" a crash in eina_file_close with invalid files.

Now I can go hunt the root cause...
2016-12-08 16:30:34 +09:00
Carsten Haitzler ed1101d994 fix possible eina file shutdown issue
i am not sure as i cannto reproduce this, but i hope this fixes T4677
by ensuring if eina_file_shutdown is called it cannto double-free a
hash.
2016-10-14 16:40:09 +09:00
Carsten Haitzler 7ee4eba33f efl - new cmp "fix" code - remove one duplicated cmp 2016-05-26 12:49:58 +09:00
Carsten Haitzler 41842ca9f9 efl - fix many bounds over/underflow where we use int for ptr cmp
this addresses more things brought up in comments in

fixes T3638 commentd

@fix
2016-05-26 12:17:07 +09:00
Jean-Philippe Andre e472f97d96 Eina: Fix eina_file_mk[ds]temp when a path is passed
If the template is a path, mkstemp and mkdtemp would fail
miserably as they would try to create a file inside
/run/user/1000//path/to/file.XXXXXX even if the path did not
exist.

This patch fixes that by creating temp files inside the sys temp
dir iif the templatename is just a basic name without path
separator.

@fix
2016-01-19 18:18:29 +09:00
Vincent Torri 9e5852fcfb eina: use eina_file_path_join() and eina_environment_tmp_get() when needed
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-12-01 12:13:12 -08:00
Vincent Torri a1243410a7 eina/efreet: open file with binary file on Windows
@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-11-06 10:53:29 -08:00
Cedric BAIL a089818335 eina: correctly prepare path before sanitizing it. 2015-10-28 06:45:10 +01:00
Cedric BAIL 046d806388 Revert "Eina: Fix 58b194e0ad56fe83cce3946a5deb0045ee0cbce2"
This reverts commit 22b45f220c.

eina_file_cleanup always does an eina_tmpstr_del. This is now capable of doing
double or even triple free in some case.
2015-10-28 06:38:14 +01:00
Vincent Torri 22b45f220c Eina: Fix 58b194e0ad
Fixes the windows build as it has a matching implementation for eina_file_cleanup.

Fixes T2804
2015-10-28 03:34:10 +01:00
Cedric BAIL 58b194e0ad eina: make sure to cleanup the right string. 2015-10-23 12:32:02 -07:00
Andy Williams 128a78940b eina: include blank lines in file iterator T2237
any line that would not have been included before has length == 0
2015-03-27 21:42:45 +00:00
Andy Williams a6290f8505 eina: Change newline parsing to handle crlf better
Adjust test to demonstrate failure, existing code only worked for
windows newlines on blank line.
@fix T2236
2015-03-27 09:56:22 +00:00
Jaeun Choi 3cd2801be7 eina: safety check for NULL pointer
data should not be NULL. it is used as the source of memcpy.

@fix
2015-03-19 16:15:20 +09:00
Tom Hacohen 8fbee3fac0 Eina tmpstr: remove usage of tmpstr_strlen(). 2015-02-09 14:02:40 +00:00
Daniel Hirt 7143bd7fb5 eina: fix valgrind invalid read of size in eina_file_path_sanitize.
Summary:
Apparently eina_tmpstr_strlen counts the null character as well. This
doesn't follow how strlen works, as the latter excludes it from the count.
This resulted in mistreatment of the string in _eina_file_escape, with
tmp_str paths that had "../".

This fix will do for now, but it is advised that we avoid using
eina_tmpstr_strlen, to prevent such confusions in the future.

Test Plan:
The following lines will throw a valgrind 'invalid read of size 1' error
prior this fix:
  char *path = "home/mydir/../myfile";
  Eina_Tmpstr *tmp_str = eina_tmpstr_add(path);
  char *ret_path = eina_file_path_sanitize(path);

@fix

Reviewers: cedric, stefan_schmidt

Subscribers: tasn, cedric

Differential Revision: https://phab.enlightenment.org/D1929

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-02-04 14:08:36 +01:00
Daniel Hirt 7cbf22212f Revert "eina: eina_file - fix "invalid read of size 1" in valgrind"
This reverts commit f52f562891.

This is reverted because it breaks eina_file_path_sanitize when using
  "/../" in paths, for example:
eina_file_path_sanitize("/home/../mydir/myfile")
  returns: "/mydir/myfili"

What invalid read size does this fix? Why was no test case specified?
Anyway, this change affects too much code to leave it in like this.
2015-02-02 14:41:37 +02:00
Romain Perier f52f562891 eina: eina_file - fix "invalid read of size 1" in valgrind
@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-01-30 10:49:58 +01:00
Jean-Philippe Andre 03cc403228 Eina file: Fix calls to getenv
There seems to be an intent to check that UID==EUID
before calling getenv to get the temp directory.
But that was lost in commits 61478af3a6 and
then in e105abc99e.
2014-10-30 18:23:49 +09:00
Stefan Schmidt e105abc99e eina_file: Give TMPDIR presedence over XDG_RUNTIME_DIR when defined
XDG_RUNTIME_DIR gives us a nice securty benefit by only allowing the
same user to read wand write files.

In some configuration this is problematic though. If one looks at the
bug report this fixes  for example you can see that there are build
scripts that use a special build user.

The way this has always worked on unix is that you can define your
own tempdir with TMPDIR. When I was making the original change towards
XDG_RUNTIME_DIR I expected some trouble with it but it worked quite
well so far.

To avoid breaking scripts out there and maybe configurations we
haven't tested yet give TMPDIR precedence over XDG_RUNTIME_DIR.

Fixes T1766
2014-10-29 15:51:11 +01:00
Vincent Torri 291c546143 eina: do no use umask on Windows in eina_file_mkstemp()
umask() sets the permissions of the file to read-only on Windows
(see umask documentation on MSDN).
This breaks the creation of .edj file (epp needs to modify the
created file).
Anyway, on Windows, permissions should be given to anybody.

@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2014-09-23 16:41:32 +02:00
Stefan Schmidt 61478af3a6 eina_file: Try to use XDG_RUNTIME_DIR for tmp dir first
Instead using $TMPDIR and falling back to /tmp we now try $XDG_RUNTIME_DIR
first.

"$XDG_RUNTIME_DIR defines the base directory relative to which user-specific
non-essential runtime files and other file objects (such as sockets, named
pipes, ...) should be stored. The directory MUST be owned by the user, and
he MUST be the only one having read and write access to it. Its Unix access
mode MUST be 0700."

While improving our security by isolating these files from other users this
has the potential to break things. I have not seen any breakage in testing
but keep this commit in mind if something strange happens on your system.
2014-09-12 09:12:52 +02:00
Andrii Kroitor 38147da036 eina_file: fixing wrong return value on access problems in file copy process
Summary:
when dest directory is protected from writing success value was returned
@fix

Reviewers: seoz, cedric, Hermet

Reviewed By: Hermet

Subscribers: cedric, reutskiy.v.v

Differential Revision: https://phab.enlightenment.org/D1366
2014-08-27 19:47:16 +09:00
Daniel Kolesa 987cde5f35 Revert "eina: new API: eina_file_path_basename"
This reverts commit 68282f8c42.

This is actually not needed because of presence of basename in Evil.
2014-07-23 19:38:08 +01:00
Daniel Kolesa 68282f8c42 eina: new API: eina_file_path_basename 2014-07-23 17:04:04 +01:00
Cedric BAIL 72aca66f8d eina: win32 and linux version code are the same. Sharing code is better. 2014-07-14 15:46:54 +02:00
ChunEon Park cc68ef1f22 eina - fixed typo 2014-07-07 20:22:06 +09:00
ChunEon Park 328d28a7f4 eina/file - revert 18be4c50d9
I realized that's not a bug in eina but user usage was inccorect.
revert the patch

@fix
2014-05-31 18:34:48 +09:00
Jean-Philippe Andre e50bcc937c Eina: Fix mistake in a previous patch
Suffix length was not computed properly.
Also, the change on eina_mkstemps was a @feature:
add file extension support when creating temporary files
2014-04-02 14:53:00 +09:00
Jean-Philippe Andre 0fdb02fb51 Eina: Add support for file extensions in eina_mkstemp
Using mkstemps
2014-04-02 11:54:44 +09:00
Cedric Bail 3e89295c73 eina: fix memory leak of inserting the wrong value in the hash.
We where inserting the pointer data instead of the pointer, leading to
unaligned access on Sparc (Thanks Lutin to report it and Debian tools/infra
to help us catch it) and also a memory leak.
2014-01-11 21:38:55 +09:00
Carsten Haitzler e8c13118eb fix mingw build for setuid fix/checks 2014-01-08 22:06:41 +09:00
Carsten Haitzler b95ef3801f setuid safeness - ensure if an app that is setuid doesn't do bad things
this makes efl ignore certain env vars for thnigs and entirely removes
user modules (that no one ever used) etc. etc. to ensure that *IF* an
app is setuid, there isn't a priv escalation path that is easy.
2014-01-08 19:46:23 +09:00
Carsten Haitzler e4b029da0b eina - eina_file - fix leak of fd is fd is 0
this should fix CID 1039181
2013-12-13 21:26:05 +09:00
Cedric Bail 62b469749a eina: fix the crash seen by some during rebuild.
Before this patch, we were unconditionnaly destroying the Eina_File if that one
did change on disk. We also make sure that we remove the right entry from the cache
if the file did change there.
2013-11-21 14:49:08 +09:00