ldap/servers/plugins/uiduniq/7bit.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
New commits:
commit bce5557406be22ec69eb38e7fd3230efe6143283
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon May 20 15:09:00 2013 -0400
Ticket 47340 - Deleting a separator ',' in 7-bit check plugin arguments makes
the
server fail to start with segfault
Bug Description: If invalid or missing plugin arguments are present in the config
entry,
the server will crash at startup. This is because we were not
fully
validating all argument values.
Fix Description: Generate an appropriate error at startup when invalid settings are
detected, and gracefully exit.
https://fedorahosted.org/389/ticket/47340
Reviewed by: Noriko(Thanks!!)
diff --git a/ldap/servers/plugins/uiduniq/7bit.c b/ldap/servers/plugins/uiduniq/7bit.c
index fbcc530..ca9792b 100644
--- a/ldap/servers/plugins/uiduniq/7bit.c
+++ b/ldap/servers/plugins/uiduniq/7bit.c
@@ -699,6 +699,7 @@ NS7bitAttr_Init(Slapi_PBlock *pb)
int premdn = SLAPI_PLUGIN_PRE_MODRDN_FN;
BEGIN
+ int attr_count = 0;
int argc;
char **argv;
@@ -731,12 +732,12 @@ NS7bitAttr_Init(Slapi_PBlock *pb)
* Arguments before "," are the 7-bit attribute names. Arguments after
* "," are the subtree DN's.
*/
- if (argc < 1) { err = -1; break; }
- for(;strcmp(*argv, ",") != 0 && argc > 0; argc--, argv++)
- {};
- if (argc == 0) { err = -1; break; }
+ if (argc < 1) { err = -2; break; } /* missing arguments */
+ for(;*argv && strcmp(*argv, ",") != 0 && argc > 0;
attr_count++, argc--, argv++);
+ if (argc == 0) { err = -3; break; } /* no comma separator */
+ if(attr_count == 0){ err = -4; break; } /* no attributes */
argv++; argc--;
-
+ if(argc == 0){ err = -5; break; } /* no suffix */
for(;argc > 0;argc--, argv++) {
char *normdn = slapi_create_dn_string_case("%s", *argv);
slapi_ch_free_string(argv);
@@ -761,9 +762,22 @@ NS7bitAttr_Init(Slapi_PBlock *pb)
END
if (err) {
- slapi_log_error(SLAPI_LOG_PLUGIN, "NS7bitAttr_Init",
- "Error: %d\n", err);
- err = -1;
+ if(err == -1){
+ slapi_log_error(SLAPI_LOG_PLUGIN, "NS7bitAttr_Init","Error:
%d\n", err);
+ } else if(err == -2){
+ slapi_log_error(SLAPI_LOG_FATAL, "NS7bitAttr_Init",
+ "Invalid plugin arguments - missing arguments\n");
+ } else if(err == -3){
+ slapi_log_error(SLAPI_LOG_FATAL, "NS7bitAttr_Init",
+ "Invalid plugin arguments - missing \",\" separator
argument\n");
+ } else if(err == -4){
+ slapi_log_error(SLAPI_LOG_FATAL, "NS7bitAttr_Init",
+ "Invalid plugin arguments - missing attributes\n");
+ } else if(err == -5){
+ slapi_log_error(SLAPI_LOG_FATAL, "NS7bitAttr_Init",
+ "Invalid plugin arguments - missing suffix\n");
+ }
+ err = -1;
}
else
slapi_log_error(SLAPI_LOG_PLUGIN, "NS7bitAttr_Init",