1
0
Эх сурвалжийг харах

Merge branch 'compile-issues' into maint

* compile-issues:
  * Use ftruncate() when writing binary
  * Properly catch fatal errors writing temp files needed during compile
Bryan Drewery 16 жил өмнө
parent
commit
67c6346cb0
4 өөрчлөгдсөн 23 нэмэгдсэн , 8 устгасан
  1. 2 3
      src/binary.c
  2. 5 2
      src/makehelp.c
  3. 11 2
      src/makeres.c
  4. 5 1
      src/makeset.c

+ 2 - 3
src/binary.c

@@ -199,13 +199,12 @@ bin_checksum(const char *fname, int todo)
     if (!(todo & GET_CHECKSUM))
     if (!(todo & GET_CHECKSUM))
       OPENSSL_cleanse(hash, sizeof(hash));
       OPENSSL_cleanse(hash, sizeof(hash));
 
 
+    if (ftruncate(newbin->fd, size)) goto fatal;
+
     /* Copy everything up to this point into the new binary (including the settings header/prefix) */
     /* Copy everything up to this point into the new binary (including the settings header/prefix) */
     outmap = (unsigned char*) mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, newbin->fd, 0);
     outmap = (unsigned char*) mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, newbin->fd, 0);
     if ((void*)outmap == MAP_FAILED) goto fatal;
     if ((void*)outmap == MAP_FAILED) goto fatal;
 
 
-    if (lseek(newbin->fd, size - 1, SEEK_SET) == -1) goto fatal;
-    if (write(newbin->fd, "", 1) != 1) goto fatal;
-
     offset += PREFIXLEN;
     offset += PREFIXLEN;
     memcpy(outmap, map, offset);
     memcpy(outmap, map, offset);
 
 

+ 5 - 2
src/makehelp.c

@@ -88,9 +88,12 @@ help_t help[] = \n\
     }
     }
   }
   }
   out << "#endif /* HELP_H */\n";
   out << "#endif /* HELP_H */\n";
-  printf(" Success\n");
 
 
-  out.writeFile(outfile);
+  if (out.writeFile(outfile)) {
+    fprintf(stderr, "Failure writing %s\n", outfile.c_str());
+    return 1;
+  }
+  printf(" Success\n");
   return 0;
   return 0;
 }
 }
 
 

+ 11 - 2
src/makeres.c

@@ -79,10 +79,19 @@ typedef const char * res_t;\n\n");
       outs << buf.printf("\t\"%s\",\n", buffer.c_str());
       outs << buf.printf("\t\"%s\",\n", buffer.c_str());
     }
     }
   }
   }
+
+  if (out.writeFile(outFile)) {
+    fprintf(stderr, "Failure writing %s\n", outFile.c_str());
+    return 1;
+  }
+
+  if (outs.writeFile(outsFile)) {
+    fprintf(stderr, "Failure writing %s\n", outsFile.c_str());
+    return 1;
+  }
+
   printf(" Success\n");
   printf(" Success\n");
 
 
-  out.writeFile(outFile);
-  outs.writeFile(outsFile);
   return 0;
   return 0;
 }
 }
 
 

+ 5 - 1
src/makeset.c

@@ -41,5 +41,9 @@ int main(int argc, char *argv[]) {
     }
     }
   }
   }
 
 
-  out.writeFile(argv[2]);
+  if (out.writeFile(argv[2])) {
+    fprintf(stderr, "Failure writing %s\n", argv[2]);
+    return 1;
+  }
+  return 0;
 }
 }