Skip to content

Instantly share code, notes, and snippets.

@lamby
Created December 11, 2015 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamby/2d9f1c62ec4f633b63c9 to your computer and use it in GitHub Desktop.
Save lamby/2d9f1c62ec4f633b63c9 to your computer and use it in GitHub Desktop.
--- a/debian/patches/series 2015-12-11 13:42:41.897386010 +0200
--- b/debian/patches/series 2015-12-11 13:54:27.564380251 +0200
@@ -7,3 +7,4 @@
hardening2
hardening3
reproducible_remove_datetime
+source_date_epoch
--- a/debian/patches/source_date_epoch 1970-01-01 02:00:00.000000000 +0200
--- b/debian/patches/source_date_epoch 2015-12-11 14:09:38.638593817 +0200
@@ -0,0 +1,52 @@
+--- brickos-0.9.0.dfsg.orig/util/dll-src/genlds.c
++++ brickos-0.9.0.dfsg/util/dll-src/genlds.c
+@@ -26,6 +26,9 @@
+ #include <stdio.h>
+ #include <time.h>
+ #include <string.h>
++#include <errno.h>
++#include <limits.h>
++#include <stdlib.h>
+
+ #define MAX_SYMBOLS 65536 //!< max symbols, enough for the RCX
+ #define MAX_SYMLEN 256 //!< max symbol length.
+@@ -285,6 +288,9 @@ int main(int argc, char *argv[]) {
+ unsigned ram,kernlen,ramlen;
+ time_t now_time;
+ char *now;
++ char *endptr;
++ char *source_date_epoch;
++ unsigned long long epoch;
+
+ // determine kernel name
+ //
+@@ -306,6 +312,29 @@ int main(int argc, char *argv[]) {
+ // create timestamp
+ //
+ now_time=time(NULL);
++ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++ if (source_date_epoch) {
++ errno = 0;
++ epoch = strtoull(source_date_epoch, &endptr, 10);
++ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
++ || (errno != 0 && epoch == 0)) {
++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n", strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++ if (endptr == source_date_epoch) {
++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endptr);
++ exit(EXIT_FAILURE);
++ }
++ if (*endptr != '\0') {
++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endptr);
++ exit(EXIT_FAILURE);
++ }
++ if (epoch > ULONG_MAX) {
++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu \n", ULONG_MAX, epoch);
++ exit(EXIT_FAILURE);
++ }
++ now_time = (time_t)epoch;
++ }
+ now =ctime(&now_time);
+
+ // print linker script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment