Browse Source

Bug 630094 - (cov#15581) Add missing breaks in agt_mopen_stats()

The switch statements in agt_mopen_stats() are missing breaks to
prevent falling through to the next case when the stats file is
opened in read-only mode. This looks like it causes the stats file
to get opened a second time in read/write mode when ldap-agent
attempts to open it in read-only mode. This may leak file
descriptors in ldap-agent.

We need to add the proper break statements.
Nathan Kinder 15 years ago
parent
commit
245d178328
1 changed files with 4 additions and 1 deletions
  1. 4 1
      ldap/servers/slapd/agtmmap.c

+ 4 - 1
ldap/servers/slapd/agtmmap.c

@@ -178,6 +178,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
 		   fprintf (stderr, "%s@%d> opened fp = %d\n",  __FILE__, __LINE__, fp);
 #endif
 		   rc = 0;
+		   break;
 		   
 	     case O_RDWR:
 	           fd = open (path, 
@@ -225,7 +226,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
 		   *hdl = 1;
 
 		   rc = 0;
-
+                   break;
 	} /* end switch */
 #else
 	/* _WIN32 */
@@ -273,6 +274,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
 			*hdl = 0;
 
 			rc = 0;
+			break;
 		}
 		
 		case O_RDWR:
@@ -317,6 +319,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
 			*hdl = 1;
 
 			rc = 0;
+			break;
 
 		}