Skip to contentSkip to conversation

mcstrans: fix glob() error checking

PATCH In review Stephen Smalley 2 participants 5 messages Jun 4 – Jun 5 SELinux security module

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/2 mcstrans: fix glob() error checking

glob(3) returns 0 on success, > 0 on various error conditions.

---
 mcstrans/src/mcstrans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mcstrans/src/mcstrans.c +1 -1
index 15c2d76b..e0593c76 100644
@@ -854,7 +854,7 @@ static int process_trans(char *buffer)
 		unsigned int n;
 		glob_t g;
 		g.gl_offs = 0;
-		if (glob(tok, GLOB_ERR, NULL, &g) < 0) {
+		if (glob(tok, GLOB_ERR, NULL, &g) != 0) {
 			globfree(&g);
 			return -1;
 		}
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH 2/2 restorecond: fix glob() error checking

glob(3) returns 0 on success, > 0 on various error conditions.

---
 restorecond/watch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
restorecond/watch.c +1 -1
index b197bdc2..bfaf4f29 100644
@@ -193,7 +193,7 @@ void watch_list_add(int fd, const char *path)
 	globbuf.gl_lstat = nofollow_lstat;
 	globbuf.gl_stat = nofollow_lstat; /* never follow symlinks */
 	if (glob(path, GLOB_TILDE | GLOB_PERIOD | GLOB_ALTDIRFUNC, NULL,
-		 &globbuf) >= 0) {
+		 &globbuf) == 0) {
 		for (i = 0; i < globbuf.gl_pathc; i++) {
 			const char *p = globbuf.gl_pathv[i];
 
Signature · 1 line
2.54.0
author maintainer
#2 lore raw

Re: [PATCH 2/2] restorecond: fix glob() error checking

Quoted 4 lines · Stephen Smalley

glob(3) returns 0 on success, > 0 on various error conditions.

This series was merged.

Quoted 20 lines
---
 restorecond/watch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
restorecond/watch.c +1 -2
index b197bdc2..bfaf4f29 100644
@@ -193,7 +193,7 @@ void watch_list_add(int fd, const char *path)
        globbuf.gl_lstat = nofollow_lstat;
        globbuf.gl_stat = nofollow_lstat; /* never follow symlinks */
        if (glob(path, GLOB_TILDE | GLOB_PERIOD | GLOB_ALTDIRFUNC, NULL,
-                &globbuf) >= 0) {
+                &globbuf) == 0) {
                for (i = 0; i < globbuf.gl_pathc; i++) {
                        const char *p = globbuf.gl_pathv[i];
 
--

2.54.0

Acked-by on v1 1/2
#3 lore raw
In reply to Stephen Smalley
Quoted 4 lines · Stephen Smalley

glob(3) returns 0 on success, > 0 on various error conditions.

For these two patches:

Quoted 20 lines
---
 mcstrans/src/mcstrans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mcstrans/src/mcstrans.c +1 -2
index 15c2d76b..e0593c76 100644
@@ -854,7 +854,7 @@ static int process_trans(char *buffer)
                unsigned int n;
                glob_t g;
                g.gl_offs = 0;
-               if (glob(tok, GLOB_ERR, NULL, &g) < 0) {
+               if (glob(tok, GLOB_ERR, NULL, &g) != 0) {
                        globfree(&g);
                        return -1;
                }
--

2.54.0

author maintainer
#4 lore raw
Quoted 10 lines · James Carter
Quoted 4 lines · Stephen Smalley

glob(3) returns 0 on success, > 0 on various error conditions.

For these two patches:

Merged.

Quoted 21 lines
Quoted 21 lines
---
 mcstrans/src/mcstrans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mcstrans/src/mcstrans.c +1 -2
index 15c2d76b..e0593c76 100644
@@ -854,7 +854,7 @@ static int process_trans(char *buffer)
                unsigned int n;
                glob_t g;
                g.gl_offs = 0;
-               if (glob(tok, GLOB_ERR, NULL, &g) < 0) {
+               if (glob(tok, GLOB_ERR, NULL, &g) != 0) {
                        globfree(&g);
                        return -1;
                }
--

2.54.0