diff --git a/src/elogd.c b/src/elogd.c index 544b1dc3..aca5516e 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.647 2005/05/05 09:26:16 ritt + Added error handling for invalid XML file + Revision 1.646 2005/05/02 15:19:01 ritt Changed wrong sizeof(), thanks to Emiliano @@ -1202,6 +1205,7 @@ typedef int INT; #define EL_EMPTY 7 #define EL_MEM_ERROR 8 #define EL_DUPLICATE 9 +#define EL_INVAL_FILE 10 #define EL_FIRST 1 #define EL_LAST 2 @@ -1457,8 +1461,8 @@ int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], char value[][NAME_ char attrib[][NAME_LENGTH], BOOL format_date); void highlight_searchtext(regex_t * re_buf, char *src, char *dst, BOOL hidden); int parse_config_file(char *config_file); -PMXML_NODE load_password_file(LOGBOOK * lbs); -void load_password_files(); +PMXML_NODE load_password_file(LOGBOOK * lbs, char *error, int error_size); +int load_password_files(); /*---- Funcions from the MIDAS library -----------------------------*/ @@ -4400,7 +4404,8 @@ int el_index_logbooks() free_logbook_hierarchy(phier); } - load_password_files(); + if (!load_password_files()) + return EL_INVAL_FILE; return EL_SUCCESS; } @@ -19228,12 +19233,15 @@ BOOL convert_password_file(char *file_name) /*------------------------------------------------------------------*/ -PMXML_NODE load_password_file(LOGBOOK * lbs) +PMXML_NODE load_password_file(LOGBOOK * lbs, char *error, int error_size) { PMXML_NODE root, list, xml_tree; char str[256], line[256], file_name[256]; int fh; + if (error) + error[0] = 0; + if (!get_password_file(lbs, file_name, sizeof(file_name))) return NULL; @@ -19243,10 +19251,11 @@ PMXML_NODE load_password_file(LOGBOOK * lbs) if (fh < 0) { fh = open(file_name, O_CREAT | O_RDWR, 0600); if (fh < 0) { - sprintf(str, loc("Cannot open file %s"), file_name); + sprintf(str, loc("Cannot open file \"%s\""), file_name); strcat(str, ": "); strlcat(str, strerror(errno), sizeof(str)); show_error(str); + strlcpy(error, str, error_size); return NULL; } close(fh); @@ -19264,13 +19273,18 @@ PMXML_NODE load_password_file(LOGBOOK * lbs) read(fh, line, sizeof(line)); close(fh); if (strstr(line, "