4
0
Эх сурвалжийг харах

Properly check result of stat func in coroparse

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
(cherry picked from commit 966f461b69321b118470c1d9b5669648b3a952dd)
Jan Friesse 12 жил өмнө
parent
commit
989f49e14d
1 өөрчлөгдсөн 4 нэмэгдсэн , 4 устгасан
  1. 4 4
      exec/coroparse.c

+ 4 - 4
exec/coroparse.c

@@ -276,8 +276,8 @@ static int read_uidgid_files_into_objdb(
 		return_code = readdir_r(dp, entry, &dirent)) {
 
 		snprintf(filename, sizeof (filename), "%s/%s", dirname, dirent->d_name);
-		stat (filename, &stat_buf);
-		if (S_ISREG(stat_buf.st_mode)) {
+		res = stat (filename, &stat_buf);
+		if (res == 0 && S_ISREG(stat_buf.st_mode)) {
 
 			fp = fopen (filename, "r");
 			if (fp == NULL) continue;
@@ -333,8 +333,8 @@ static int read_service_files_into_objdb(
 		return_code = readdir_r(dp, entry, &dirent)) {
 
 		snprintf(filename, sizeof (filename), "%s/%s", dirname, dirent->d_name);
-		stat (filename, &stat_buf);
-		if (S_ISREG(stat_buf.st_mode)) {
+		res = stat (filename, &stat_buf);
+		if (res == 0 && S_ISREG(stat_buf.st_mode)) {
 
 			fp = fopen (filename, "r");
 			if (fp == NULL) continue;