💾 Archived View for thrig.me › blog › 2022 › 12 › 05 › nowa.patch captured on 2023-11-04 at 12:49:50.

View Raw

More Information

⬅️ Previous capture (2023-07-10)

-=-=-=-=-=-=-

diff --git .gitignore .gitignore
index 46fb393..1449541 100644
--- .gitignore
+++ .gitignore
@@ -81,3 +81,6 @@ tags
 # Docker
 
 Dockerfile
+
+*.core
+ktrace.out
diff --git src/forecast.c src/forecast.c
index e0961f2..ac498b2 100644
--- src/forecast.c
+++ src/forecast.c
@@ -71,7 +71,7 @@ status_t print_forecast(char station_id[restrict static 1]) {
   printf("%s %c, %s %c\n", dms_latitude, latdir, dms_longitude, lngdir);
 
   char *update_string = checked_calloc(1, 61 * sizeof *update_string);
-  long ts = mktime(&last_updated) - timezone;
+  time_t ts = mktime(&last_updated) - timezone;
   localtime_r(&ts, &last_updated);
   strftime(update_string, 61, "Last Updated: %A, %d %B %Y, %I:%M:%S %p %Z",
            &last_updated);
diff --git src/nowa.c src/nowa.c
index 011de4f..19a26cc 100644
--- src/nowa.c
+++ src/nowa.c
@@ -1,3 +1,6 @@
+#include <err.h>
+#include <unistd.h>
+
 /*
  * nowa.c
  *
@@ -47,6 +50,13 @@ status_t status = ERR_OK;
 static void print_usage(void);
 
 int main(int argc, char *argv[]) {
+#ifdef __OpenBSD__
+    if (pledge("dns inet rpath stdio unveil", NULL) == -1)
+        err(1, "pledge failed");
+    if (unveil(NULL, NULL) == -1)
+        err(1, "unveil failed");
+#endif
+
   if (argc == 1) {
     print_usage();
     return EXIT_SUCCESS;