bugfix for #7254 (Don't get confused entirely by corrupted database and handle
authorDaniel Kouřil <kouril@ics.muni.cz>
Tue, 15 Mar 2005 17:48:22 +0000 (17:48 +0000)
committerDaniel Kouřil <kouril@ics.muni.cz>
Tue, 15 Mar 2005 17:48:22 +0000 (17:48 +0000)
memory (de)allocations correctly)

org.glite.security.proxyrenewal/project/version.properties
org.glite.security.proxyrenewal/src/commands.c

index e27af18..9a46fde 100644 (file)
@@ -1,4 +1,4 @@
 
-module.version = 1.0.3
+module.version = 1.0.4
 module.age = 1
                                
index 77b1a60..a83a32e 100644 (file)
@@ -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;