Re: [PATCH 2/2] secilc: better error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ack

On Mon, Sep 24, 2018 at 11:12 AM Nick Kralevich via Selinux <selinux@xxxxxxxxxxxxx> wrote:
Fix a situation where the secilc command line tool could return success
even though the compilation failed.

  $ secilc /dev/null -o /dev/null -f /dev/null
  Failure reading file: /dev/null
  $ echo $?
  0

Signed-off-by: Nick Kralevich <nnk@xxxxxxxxxx>
---
 secilc/secilc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/secilc/secilc.c b/secilc/secilc.c
index e1347205..ad6862ba 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -257,6 +257,7 @@ int main(int argc, char *argv[])
                rc = stat(argv[i], &filedata);
                if (rc == -1) {
                        fprintf(stderr, "Could not stat file: %s\n", argv[i]);
+                       rc = SEPOL_ERR;
                        goto exit;
                }
                file_size = filedata.st_size;
@@ -265,6 +266,7 @@ int main(int argc, char *argv[])
                rc = fread(buffer, file_size, 1, file);
                if (rc != 1) {
                        fprintf(stderr, "Failure reading file: %s\n", argv[i]);
+                       rc = SEPOL_ERR;
                        goto exit;
                }
                fclose(file);
@@ -345,11 +347,13 @@ int main(int argc, char *argv[])

        if (file_contexts == NULL) {
                fprintf(stderr, "Failed to open file_contexts file\n");
+               rc = SEPOL_ERR;
                goto exit;
        }

        if (fwrite(fc_buf, sizeof(char), fc_size, file_contexts) != fc_size) {
                fprintf(stderr, "Failed to write file_contexts file\n");
+               rc = SEPOL_ERR;
                goto exit;
        }

--
2.19.0.444.g18242da7ef-goog

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.
_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.

[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux