-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: shell-daemons
action: commit
revision:
path_from:
revision_from: ef516d5efbcd3e35bc034aa2d2fc9932f6a4e4c1:
path_to:
revision_to:

git.thebackupbox.net

shell-daemons

git://git.thebackupbox.net/shell-daemons

commit ef516d5efbcd3e35bc034aa2d2fc9932f6a4e4c1
Author: epoch <epoch@thebackupbox.net>
Date:   Mon Aug 1 07:05:30 2022 +0000

    made read_headers not explode when ran naively.

diff --git a/read_headers.c b/read_headers.c

index efa71227f3fa46461b08dfdf5e227fca2b091abd..

index ..a86730b139528da7c49561d566b33bcc9a65ddd4 100644

--- a/read_headers.c
+++ b/read_headers.c
@@ -18,10 +18,12 @@ char convert(char in) {
 int main(int argc,char *argv[]) {
   int i;
   char line[8192];//lol. how long should this be?
-  char scheme[512];
+  char scheme[512]="(undefined)";
   char name[8192 + 512 + 1];
   char *value;
-  strcpy(scheme,getenv("SERVER_PROTOCOL"));
+  if(getenv("SERVER_PROTOCOL")) {
+    strncpy(scheme,getenv("SERVER_PROTOCOL"),sizeof(scheme)-1);
+  }
   if(strchr(scheme,'/')) *strchr(scheme,'/')=0;
   while(fgets(line,sizeof(line)-1,stdin)) {
     if(strchr(line,'\n')) *strchr(line,'\n')=0;
@@ -29,9 +31,9 @@ int main(int argc,char *argv[]) {
     if(!strlen(line)) break;//got a blank line. abort.
     if((value=strchr(line,':'))) {
       *value=0;
-      for(value++;*value==' ';value++);
+      for(value++;*value==' ';value++);//collapse leading whitespace in values
     } else {
-      continue;
+      continue;//lines missing a : aren't key: value pairs. skip I guess.
     }
     strcpy(name,scheme);
     strcat(name,"_");

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 09:28:25 2024