libselinux: Add missing errno setup
PATCH 1/1 libselinux: Add missing errno setup
Errno is not set to ENOENT when lookup_all() doesn't find any match.
--- libselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)
libselinux/src/label_file.c +2 -0
@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (result && !result[0 ]) + errno =ENOENT ; finish:free (clean_key);
Signature · 1 line
2.25.2
Hi,
Quoted 4 lines · Richard Filo
Errno is not set to ENOENT when
lookup_all()doesn't find any match.
Please put the issue link after the explanation (the link is just additional information).
Also, you need to add a "Signed-off-by:" line to the end of the commit message (for legal reasons), see:
https://github.com/SELinuxProject/selinux/blob/master/CONTRIBUTING.md#contributing-code
https://opensource.com/article/18/3/cla-vs-dco-whats-difference
libselinux/src/label_file.c static const struct spec **lookup_all(struct selabel_handle *rec, · line 951
Quoted 13 lines
--- libselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)libselinux/src/label_file.c +1
-0@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (result && !result[0 ])
'result' can never be NULL here, so you can drop the first part of the check.
Quoted 7 lines
libselinux/src/label_file.c +1
-1+ errno =ENOENT ; finish:free (clean_key); --2.25.2
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
PATCH v2 1/1 libselinux: Add missing errno setup
Errno is not set to ENOENT when lookup_all() doesn't find any match.
--- libselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)
libselinux/src/label_file.c +2 -0
@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (result && !result[0 ]) + errno =ENOENT ; finish:free (clean_key);
Signature · 1 line
2.25.2
Quoted 14 lines · Richard Filo
Errno is not set to ENOENT when
lookup_all()doesn't find any match.Signed-off-by Richard Filo <[email protected]>--- libselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)libselinux/src/label_file.c +0
-0
libselinux/src/label_file.c static const struct spec **lookup_all(struct selabel_handle *rec, · line 952
Quoted 5 lines
libselinux/src/label_file.c +2
-0@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (result && !result[0 ]) + errno =ENOENT ;
Sorry for not spotting this earlier, but there is no need to check if result != NULL, because it will always be non-NULL at this point. So you should only do the second part of the check (!result[0]). The check under the "finish" label needs to check both, because you can get there also via the allocation-failed path, where "result" would be NULL.
Quoted 6 lines
libselinux/src/label_file.c +0
-1finish:free (clean_key); --2.25.2
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
PATCH v3 1/1 libselinux: Add missing errno setup
Errno is not set to ENOENT when lookup_all() doesn't find any match.
---
-removed check: result != NULL
libselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)
libselinux/src/label_file.c +2 -0
@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (!result[0 ]) + errno =ENOENT ; finish:free (clean_key);
Signature · 1 line
2.25.2
Quoted 25 lines · Richard Filo
Errno is not set to ENOENT when
lookup_all()doesn't find any match.Signed-off-by Richard Filo <[email protected]>---
-removed check: result != NULLlibselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)libselinux/src/label_file.c +2
-1@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (!result[0 ]) + errno =ENOENT ; finish:free (clean_key); --
Quoted 1 line
2.25.2
Thanks!
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Software Engineer, Security Technologies Red Hat, Inc.
Quoted 23 lines · Ondrej Mosnacek
Quoted 22 lines · Richard Filo
Errno is not set to ENOENT when
lookup_all()doesn't find any match.Signed-off-by Richard Filo <[email protected]>---
-removed check: result != NULLlibselinux/src/label_file.c | 2 ++ 1 file changed, 2 insertions(+)libselinux/src/label_file.c +2
-0@@ -948,6 +948,8 @@ static const struct spec **lookup_all(struct selabel_handle *rec, goto finish; } } +if (!result[0 ]) + errno =ENOENT ;
Quoted 9 lines
Quoted 4 lines
libselinux/src/label_file.c +0
-1finish:free (clean_key); --2.25.2
Acked-by Ondrej Mosnacek <[email protected]>Thanks!
^&^ git am v3-libselinux-Add-missing-errno-setup.patch
Applying: libselinux: Add missing errno setup .git/rebase-apply/patch:15: trailing whitespace.
if (!result[0])
warning: 1 line adds whitespace errors.
I have fixed the trailing whitespace and applied it.
Thanks.