]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
AOSP: e2fsdroid: Fix incorrect error value handling.
authorDavid Anderson <dvander@google.com>
Thu, 24 Jan 2019 02:49:23 +0000 (18:49 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 8 Feb 2019 03:37:54 +0000 (22:37 -0500)
Methods returning 0 or -1 should not pass their return value to com_err.
Also, errno values should not be negated when passed to com_err or
through errcode_t.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Bug: N/A
Test: manual test

Change-Id: I5e25cf2deeee72668bf0ab58337ee582bf14bbc1
From AOSP commit: 0468e33fba75dbf60877ef14ecee7b0b60f756df

contrib/android/perms.c

index 3c42e5977afb387fbd0176bd6a35bae80cbbf696..9c5ec05bc8a669bd8f6877a60b26b7130c9656f7 100644 (file)
@@ -81,9 +81,10 @@ static errcode_t set_selinux_xattr(ext2_filsys fs, ext2_ino_t ino,
        retval = selabel_lookup(params->sehnd, &secontext, params->filename,
                                inode.i_mode);
        if (retval < 0) {
-               com_err(__func__, retval,
+               int saved_errno = errno;
+               com_err(__func__, errno,
                        _("searching for label \"%s\""), params->filename);
-               return retval;
+               return saved_errno;
        }
 
        retval = ino_add_xattr(fs, ino,  "security." XATTR_SELINUX_SUFFIX,
@@ -187,7 +188,7 @@ static errcode_t set_timestamp(ext2_filsys fs, ext2_ino_t ino,
                }
                retval = lstat(src_filename, &stat);
                if (retval < 0) {
-                       com_err(__func__, retval,
+                       com_err(__func__, errno,
                                _("while lstat file %s"), src_filename);
                        goto end;
                }
@@ -339,18 +340,19 @@ errcode_t android_configure_fs(ext2_filsys fs, char *src_dir, char *target_out,
        if (nopt > 0) {
                sehnd = selabel_open(SELABEL_CTX_FILE, seopts, nopt);
                if (!sehnd) {
-                       com_err(__func__, -EINVAL,
+                       int saved_errno = errno;
+                       com_err(__func__, errno,
                                _("while opening file contexts \"%s\""),
                                seopts[0].value);
-                       return -EINVAL;
+                       return saved_errno;
                }
        }
 #else
        sehnd = selinux_android_file_context_handle();
        if (!sehnd) {
-               com_err(__func__, -EINVAL,
+               com_err(__func__, EINVAL,
                        _("while opening android file_contexts"));
-               return -EINVAL;
+               return EINVAL;
        }
 #endif