From: Daniel KouĊ™il Date: Tue, 15 Mar 2005 17:48:22 +0000 (+0000) Subject: bugfix for #7254 (Don't get confused entirely by corrupted database and handle X-Git-Tag: glite-security-proxyrenewal_R_1_0_10~24 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=76b9feebadb3c9e4face43659081572d1d391aa9;p=jra1mw.git bugfix for #7254 (Don't get confused entirely by corrupted database and handle memory (de)allocations correctly) --- diff --git a/org.glite.security.proxyrenewal/project/version.properties b/org.glite.security.proxyrenewal/project/version.properties index e27af18..9a46fde 100644 --- a/org.glite.security.proxyrenewal/project/version.properties +++ b/org.glite.security.proxyrenewal/project/version.properties @@ -1,4 +1,4 @@ -module.version = 1.0.3 +module.version = 1.0.4 module.age = 1 diff --git a/org.glite.security.proxyrenewal/src/commands.c b/org.glite.security.proxyrenewal/src/commands.c index 77b1a60..a83a32e 100644 --- a/org.glite.security.proxyrenewal/src/commands.c +++ b/org.glite.security.proxyrenewal/src/commands.c @@ -521,19 +521,23 @@ get_record_ext(FILE *fd, proxy_record *record, int *last_used_suffix) char *p; proxy_record tmp_record; time_t current_time; + int line_num = 0; assert(record != NULL); memset(&tmp_record, 0, sizeof(tmp_record)); current_time = time(NULL); while (fgets(line, sizeof(line), fd) != NULL) { + line_num++; free_record(&tmp_record); p = strchr(line, '\n'); if (p) *p = '\0'; ret = decode_record(line, &tmp_record); - if (ret) - return ret; /* XXX continue */ + if (ret) { + edg_wlpr_Log(LOG_ERR, "Skipping invalid entry at line %d", line_num); + continue; + } if (record->suffix >= 0) { if (record->suffix == tmp_record.suffix) { record->suffix = tmp_record.suffix; @@ -564,10 +568,8 @@ get_record_ext(FILE *fd, proxy_record *record, int *last_used_suffix) * parameters (currently myproxy location) provided by user */ char *server = record->myproxy_server; - memset(record, sizeof(*record), 0); + memset(record, 0, sizeof(*record)); record->suffix = tmp_record.suffix; - if (record->myproxy_server) - free(record->myproxy_server); record->myproxy_server = server; free_record(&tmp_record); return 0; @@ -632,6 +634,7 @@ store_record(char *basename, proxy_record *record) proxy_record tmp_record; char tmp_file[FILENAME_MAX]; char meta_file[FILENAME_MAX]; + int line_num = 0; assert (record != NULL); @@ -650,13 +653,16 @@ store_record(char *basename, proxy_record *record) goto end; } while (fgets(line, sizeof(line), fd) != NULL) { + line_num++; free_record(&tmp_record); p = strchr(line, '\n'); if (p) *p = '\0'; ret = decode_record(line, &tmp_record); - if (ret) - goto end; + if (ret) { + edg_wlpr_Log(LOG_ERR, "Removing invalid entry at line %d in %s", line_num, basename); + continue; + } if (record->suffix == tmp_record.suffix && record->unique == tmp_record.unique) { tmp_record.next_renewal = record->next_renewal;