Skip to content

Commit

Permalink
fixed ezmlm for gcc14
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhangui committed Jan 21, 2025
1 parent 5af13d7 commit 2942f92
Show file tree
Hide file tree
Showing 33 changed files with 2,873 additions and 2,193 deletions.
74 changes: 37 additions & 37 deletions ezmlm-x/cookie.c
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
/*
* $Id: $
*/
#include "cookie.h"
#include "str.h"
#include "uint32.h"
#include "surfpcs.h"

void cookie(hash,key,keylen,date,addr,action)
char *hash;
char *key;
unsigned int keylen;
char *date;
char *addr;
char *action;
void
cookie(char *hash, char *key, size_t keylen, char *date, char *addr, char *action)
{
surfpcs s;
uint32 seed[32];
unsigned char out[32];
int i;
int j;
surfpcs s;
uint32 seed[32];
unsigned char out[32];
int i;
int j;

/*
step 1: create seed from key. note that this doesn't have to be
cryptographic; it simply has to avoid destroying the user's entropy.
if speed turns out to be a problem, switch to a CRC.
*/
for (i = 0;i < 32;++i) seed[i] = 0;
for (j = 0;j < 4;++j) {
surfpcs_init(&s,seed);
surfpcs_add(&s,key,keylen);
surfpcs_out(&s,out);
for (i = 0;i < 32;++i) seed[i] = (seed[i] << 8) + out[i];
}
/*
* step 1: create seed from key. note that this doesn't have to be
* cryptographic; it simply has to avoid destroying the user's entropy.
* if speed turns out to be a problem, switch to a CRC.
*/
for (i = 0; i < 32; ++i)
seed[i] = 0;
for (j = 0; j < 4; ++j) {
surfpcs_init(&s, seed);
surfpcs_add(&s, key, keylen);
surfpcs_out(&s, out);
for (i = 0; i < 32; ++i)
seed[i] = (seed[i] << 8) + out[i];
}

/*
step 2: apply SURF.
*/
surfpcs_init(&s,seed);
surfpcs_add(&s,date,str_len(date) + 1);
surfpcs_add(&s,addr,str_len(addr) + 1);
surfpcs_add(&s,action,1);
surfpcs_out(&s,out);
/*- step 2: apply SURF. */
surfpcs_init(&s, seed);
surfpcs_add(&s, date, str_len(date) + 1);
surfpcs_add(&s, addr, str_len(addr) + 1);
surfpcs_add(&s, action, 1);
surfpcs_out(&s, out);

/*
step 3: extract a readable cookie from the SURF output.
*/
for (i = 0;i < 20;++i)
hash[i] = 'a' + (out[i] & 15);
/*- step 3: extract a readable cookie from the SURF output. */
for (i = 0; i < 20; ++i)
hash[i] = 'a' + (out[i] & 15);
}

/*
* $Log: $
*/
3 changes: 2 additions & 1 deletion ezmlm-x/cookie.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef COOKIE_H
#define COOKIE_H
#include <sys/types.h>

#define COOKIE 20

extern void cookie();
extern void cookie(char *, char *, size_t, char *, char *, char *);

#endif
99 changes: 54 additions & 45 deletions ezmlm-x/ezmlm-list.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
* $Id: $
*/
#include <unistd.h>
#include "stralloc.h"
#include "substdio.h"
Expand All @@ -8,55 +11,61 @@
#include "open.h"

#define FATAL "ezmlm-list: fatal: "
void die_write()

char outbuf[1024], inbuf[1024];
substdio out = SUBSTDIO_FDBUF((ssize_t(*)(int, char *, size_t)) write, 1, outbuf, sizeof (outbuf));
substdio in;
stralloc line = { 0 };
char fn[14] = "subscribers/?";

void
die_write()
{
strerr_die2sys(111,FATAL,"unable to write: ");
strerr_die2sys(111, FATAL, "unable to write: ");
}

char outbuf[1024];
substdio out = SUBSTDIO_FDBUF(write,1,outbuf,sizeof(outbuf));
char inbuf[1024];
substdio in;
int
main(int argc, char **argv)
{
char *dir;
int fd;
int match;

stralloc line = {0};
dir = argv[1];
if (!dir)
strerr_die1x(100, "ezmlm-list: usage: ezmlm-list dir");

char fn[14] = "subscribers/?";
if (chdir(dir) == -1)
strerr_die4sys(111, FATAL, "unable to switch to ", dir, ": ");

int main(argc,argv)
int argc;
char **argv;
{
char *dir;
int fd;
int match;

dir = argv[1];
if (!dir) strerr_die1x(100,"ezmlm-list: usage: ezmlm-list dir");

if (chdir(dir) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",dir,": ");

for (fn[12] = 64;fn[12] < 64 + 53;++fn[12]) {
fd = open_read(fn);
if (fd == -1) {
if (errno != error_noent)
strerr_die4sys(111,FATAL,"unable to open ",fn,": ");
}
else {
substdio_fdbuf(&in,read,fd,inbuf,sizeof(inbuf));
for (;;) {
if (getln(&in,&line,&match,'\0') == -1)
strerr_die4sys(111,FATAL,"unable to read ",fn,": ");
if (!match) break;
if (line.s[str_chr(line.s,'\n')])
strerr_die3x(111,FATAL,"newline in ",fn);
if (substdio_puts(&out,line.s + 1)) die_write();
if (substdio_put(&out,"\n",1) == -1) die_write();
}
}

}

if (substdio_flush(&out) == -1) die_write();
_exit(0);
for (fn[12] = 64; fn[12] < 64 + 53; ++fn[12]) {
fd = open_read(fn);
if (fd == -1) {
if (errno != error_noent)
strerr_die4sys(111, FATAL, "unable to open ", fn, ": ");
} else {
substdio_fdbuf(&in, (ssize_t(*)(int, char *, size_t)) read, fd, inbuf, sizeof (inbuf));
for (;;) {
if (getln(&in, &line, &match, '\0') == -1)
strerr_die4sys(111, FATAL, "unable to read ", fn, ": ");
if (!match)
break;
if (line.s[str_chr(line.s, '\n')])
strerr_die3x(111, FATAL, "newline in ", fn);
if (substdio_puts(&out, line.s + 1))
die_write();
if (substdio_put(&out, "\n", 1) == -1)
die_write();
}
}

}

if (substdio_flush(&out) == -1)
die_write();
_exit(0);
}

/*
* $Log: $
*/
Loading

0 comments on commit 2942f92

Please sign in to comment.