-- Leo's gemini proxy

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

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: segfault
action: commit
revision:
path_from:
revision_from: 367f2f4bdcf7b294fc77105986f8dd4f78dafcea:
path_to:
revision_to:

git.thebackupbox.net

segfault

git://git.thebackupbox.net/segfault

commit 367f2f4bdcf7b294fc77105986f8dd4f78dafcea
Author: epoch <epoch@thebackupbox.net>
Date:   Thu Mar 16 03:13:06 2023 +0000

    some old Makefile changes I never commit'd. fixed long-standing bug with too long lines being appended getting truncated.

diff --git a/.gitignore b/.gitignore

index a9418f1584b01c3a01d73bf6def177900845c5c2..

index ..3d2020bd0d75ee696149ea0eed5f63f7f47d8d0f 100644

--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,7 @@
+access.h
+libhack.o
+libhack.so
+spacify
 segfault
 libirc/libirc.o
 libirc/libirc.so
diff --git a/Makefile b/Makefile

index 9d4e4d6bf8922dce0455959d7119c28395ddb103..

index ..f75e2ff0b429b0837247dba431171a95b44cc4d5 100644

--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,9 @@ libhack.so: libhack.o

 again: clean all

-segfault: LDFLAGS=-L/usr/local/lib -L$(PREFIX)/lib -lirc -lhashtable -lgcc_s -lidc -ldl
-segfault: segfault.c access.h
+segfault: LDFLAGS=-L/usr/local/lib -L$(PREFIX)/lib
+segfault: LDLIBS=-lhashtable -lirc -lidc -ldl -lgcc_s
+segfault: segfault.c | access.h

 clean:
 	rm -f segfault
diff --git a/segfault.c b/segfault.c

index 9162892eec883d22531cd00623545ee01a7d1eff..

index ..8c22abb0f9f8f5b483b199433db8e40e788d61cf 100644

--- a/segfault.c
+++ b/segfault.c
@@ -1198,6 +1198,8 @@ void c_tailunlock(int fd,char *from,char *file,...) {
 char append_file(int fd,char *from,char *file,char *line,unsigned short nl) {
  int fdd;
  char tmp[512];
+ int sz=strlen(line)+2;// +2 because nl and null after line
+ char *line2=malloc(sz);//let's pretend malloc()s don't fail.
 // char derp[2];
 // FILE *fp;
 // derp[0]=(char)nl;
@@ -1213,8 +1215,8 @@ char append_file(int fd,char *from,char *file,char *line,unsigned short nl) {
   snprintf(tmp,sizeof(tmp)-1,"append_file opened file '%s' with fd: %d / %d / %d\n",file,fdd,currentmaxtails,maxtails);
   privmsg(fd,"#cmd",tmp);
  }
- snprintf(tmp,sizeof(tmp)-1,"%s%c",line,nl);
- mywrite(fdd,tmp);
+ snprintf(line2,sz,"%s%c",line,nl);
+ mywrite(fdd,line2);
 // dprintf(fdd,"%s\n",line);
 // fcntl(fdd,F_SETFL,O_WRONLY|O_APPEND|O_CREAT);
  close(fdd);

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

-- Response ended

-- Page fetched on Sun Jun 2 15:53:19 2024