A lot of fixes found with valgrind

This commit is contained in:
Michiel Broek 2003-12-04 22:07:33 +00:00
parent fab5a2edae
commit f0bbdba104
37 changed files with 2267 additions and 1427 deletions

View File

@ -2,24 +2,67 @@ $Id$
v0.39.3 26-Nov-2003 v0.39.3 26-Nov-2003
WARNING: NOT EVERYTHING IS TESTED, WAIT A FEW DAYS AND DON'T USE THIS.
general: general:
Since this version Posix threads are being used, please let Since this version Posix threads are being used, please let
me know if this doesn't compile on you system. me know if this doesn't compile on you system.
All Makefiles do not strip the binaries anymore, the binaries All Makefiles do not strip the binaries anymore, the binaries
are stripped during make install only. This allows to run the are stripped during make install only. This allows to run the
not yet installed binaries under debuggers. not yet installed binaries under debuggers.
The configure script has a --enable-debugging option so that
all code can be compiled to let it run under debuggers.
libclcomm:
Fixed a small (not harmfull) buffer overlapped copy detected
by valgrind.
libcommon:
Code cleanup in proglock and pktname.
Fixed a forgotten fclose in proglock.
libmsgbase:
In JAM_Open replaced a strcpy with memmove.
mbcico: mbcico:
Dropped binkp CRC support because it will be incompatible with Dropped binkp CRC support because it will be incompatible with
future extensions. future extensions.
Fixed a small memory leak.
mbfido:
Fixed a small memory leak.
mbfile:
Fixed a uninitialized memory pointer in the index command.
mbindex:
Fixed a forgotten file close.
mbsetup: mbsetup:
Removed binkp CRC settings. Removed binkp CRC settings.
Fixed a unitialized unlink call in nodes close.
Fixed unclosed tempfile.
Fixed several small memory leaks.
mbsebbs:
Fixed small memory leak.
mball:
Fixed 2 forgotten fclose functions.
mbuser:
Fixed a forgotten file close when nothing was done.
mbmon:
Fixed a minor problem with an uninitialized array.
mbtask: mbtask:
The ping function now runs in a separate thread. The ping function now runs in a separate thread.
Changed some ping timer logic. Changed some ping timer logic.
mbpasswd:
Fixed a small memory leak.
v0.39.2 21-Nov-2003 - 26-Nov-2003 v0.39.2 21-Nov-2003 - 26-Nov-2003

View File

@ -33,6 +33,7 @@ MAKE = @MAKE@
JOEBIN = @joebin@ JOEBIN = @joebin@
JOELIB = @joelib@ JOELIB = @joelib@
CFLAGS = -O2 -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -pipe CFLAGS = @COMPILEFLAGS@
LIBS = @LIBS@ LIBS = @LIBS@
PTLIBS = @PTLIBS@

18
TODO
View File

@ -29,7 +29,12 @@ libdiesel.a:
U: Processed stringlines containing unbalanced " characters are not U: Processed stringlines containing unbalanced " characters are not
processed, instead the previous macro value will be returned. processed, instead the previous macro value will be returned.
mbtask:
N: Test with valgrind.
mbsebbs: mbsebbs:
N: Test with valgrind.
X: Better word wrapping or paragraph justification in editor. X: Better word wrapping or paragraph justification in editor.
X: E-mail downloads with e-mail verification. X: E-mail downloads with e-mail verification.
@ -57,6 +62,8 @@ mbsebbs:
N: Reimplememnt CHRS kludge. N: Reimplememnt CHRS kludge.
newuser: newuser:
N: Test with valgrind.
L: Allow handles to be the same as the unixname. L: Allow handles to be the same as the unixname.
@ -108,7 +115,13 @@ mbfido:
N: With auto created areas golded.inc is not adjusted to the new N: With auto created areas golded.inc is not adjusted to the new
setup. setup.
N: After readalias we need to free the alias list when mbfido ends.
N: Tic, toss, scan tests with valgrind.
mbcico: mbcico:
N: Test with valgrind, binkp is ok.
N: Upgrade binkp protocol to 1.1. N: Upgrade binkp protocol to 1.1.
N: With binkp, if the other node is a binkp/1.0 mailer without MB N: With binkp, if the other node is a binkp/1.0 mailer without MB
@ -120,6 +133,9 @@ mbcico:
U: Fix binkp file resume when mbcico silently dies. U: Fix binkp file resume when mbcico silently dies.
mbout:
N: Fix prepbuf in libcommon so that valgind can test this.
mbfile: mbfile:
L: Add a check to see if the magic filenames are (still) valid. L: Add a check to see if the magic filenames are (still) valid.
@ -129,6 +145,8 @@ mbfile:
L: Possibility to skip file areas from checking and reindexing. L: Possibility to skip file areas from checking and reindexing.
N: Test with valgrind.
mbmsg: mbmsg:
N: With the post command if a netmail area is used the netmail area N: With the post command if a netmail area is used the netmail area
will cause trouble later, should be blocked to be used on netmail will cause trouble later, should be blocked to be used on netmail

2434
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -55,11 +55,19 @@ CFLAGS="$CFLAGS -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes"
dnl Additional commandline switches dnl Additional commandline switches
AC_ARG_ENABLE(experiment, [ --enable-experiment Compile experimental code], [ experiment=$enableval ], [ experiment=no ]) AC_ARG_ENABLE(experiment, [ --enable-experiment Compile experimental code], [ experiment=$enableval ], [ experiment=no ])
if test "$experiment" = "yes"; then if test "$experiment" = "yes"; then
AC_DEFINE(USE_EXPERIMENT) AC_DEFINE(USE_EXPERIMENT)
fi fi
AC_ARG_ENABLE(debugging, [ --enable-debugging Compile for debugging], [ debugging=$enableval ], [ debugging=no ])
if test "$debugging" = "yes"; then
COMPILEFLAGS="-O -g -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -pipe"
else
COMPILEFLAGS="-O2 -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -pipe"
fi
AC_SUBST(COMPILEFLAGS)
dnl Defines for MBSE BBS (must use tests or --enable-stuff later) dnl Defines for MBSE BBS (must use tests or --enable-stuff later)
AC_DEFINE_UNQUOTED(RESTAMP_OLD_POSTINGS, 21) AC_DEFINE_UNQUOTED(RESTAMP_OLD_POSTINGS, 21)
AC_DEFINE(RESTAMP_FUTURE_POSTINGS) AC_DEFINE(RESTAMP_FUTURE_POSTINGS)
@ -140,15 +148,16 @@ fi
PTHREADS=No PTHREADS=No
AC_CHECK_LIB(pthread,pthread_create,result=yes,result=no) AC_CHECK_LIB(pthread,pthread_create,result=yes,result=no)
if test "$result" = "yes"; then if test "$result" = "yes"; then
LIBS="$LIBS -lpthread" PTLIBS="$PTLIBS -lpthread"
AC_CHECK_HEADERS(pthread.h,PTHREADS=Yes,PTHREADS=No) AC_CHECK_HEADERS(pthread.h,PTHREADS=Yes,PTHREADS=No)
else else
AC_CHECK_LIB(c_r,pthread_create,result=yes,result=no) AC_CHECK_LIB(c_r,pthread_create,result=yes,result=no)
if test "$result" = "yes"; then if test "$result" = "yes"; then
LIBS="$LIBS -lc_r" PTLIBS="$PTLIBS -lc_r"
AC_CHECK_HEADERS(pthread.h,PTHREADS=Yes,PTHREADS=No) AC_CHECK_HEADERS(pthread.h,PTHREADS=Yes,PTHREADS=No)
fi fi
fi fi
AC_SUBST(PTLIBS)
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC

View File

@ -50,8 +50,7 @@ char cpath[108]; /* Client socket path */
int socket_connect(char *user, char *prg, char *city) int socket_connect(char *user, char *prg, char *city)
{ {
int s; int s;
static char buf[SS_BUFSIZE]; static char buf[SS_BUFSIZE], tty[18];
static char tty[18];
myname = prg; myname = prg;
@ -104,11 +103,11 @@ int socket_connect(char *user, char *prg, char *city)
if (isatty(1) && (ttyname(1) != NULL)) { if (isatty(1) && (ttyname(1) != NULL)) {
strcpy(tty, ttyname(1)); strcpy(tty, ttyname(1));
if (strchr(tty, 'p')) if (strchr(tty, 'p'))
strcpy(tty, index(tty, 'p')); memccpy(tty, index(tty, 'p'), '\0', strlen(tty));
else if (strchr(tty, 't')) else if (strchr(tty, 't'))
strcpy(tty, index(tty, 't')); memccpy(tty, index(tty, 't'), '\0', strlen(tty));
else if (strchr(tty, 'c')) else if (strchr(tty, 'c'))
strcpy(tty, index(tty, 'c')); memccpy(tty, index(tty, 'c'), '\0', strlen(tty));
} else { } else {
strcpy(tty, "-"); strcpy(tty, "-");
} }

View File

@ -303,7 +303,6 @@ int noderecord(faddr *);
/* /*
* From pktname.c * From pktname.c
*/ */
char *prepbuf(faddr *);
char *pktname(faddr *, char); char *pktname(faddr *, char);
char *reqname(faddr *); char *reqname(faddr *);
char *floname(faddr *, char); char *floname(faddr *, char);

View File

@ -10,7 +10,7 @@
* MBSE BBS and utilities. * MBSE BBS and utilities.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -566,7 +566,7 @@ int JAM_Open(char *Msgbase)
fdJlr = open(File, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP); fdJlr = open(File, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
RetVal = TRUE; RetVal = TRUE;
strcpy(BaseName, Msgbase); memmove(BaseName, Msgbase, strlen(Msgbase));
} else { } else {
close(fdHdr); close(fdHdr);
fdHdr = -1; fdHdr = -1;

View File

@ -4,7 +4,7 @@
* Purpose ...............: BinkleyTerm outbound naming * Purpose ...............: BinkleyTerm outbound naming
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -51,13 +51,12 @@
#define ltyp "pol" #define ltyp "pol"
static char buf[PATH_MAX];
char *prepbuf(faddr *);
char *prepbuf(faddr *addr) char *prepbuf(faddr *addr)
{ {
char *p, *domain=NULL; static char buf[PATH_MAX];
char zpref[8]; char *p, *domain=NULL, zpref[8];
int i; int i;
sprintf(buf, "%s", CFG.outbound); sprintf(buf, "%s", CFG.outbound);
@ -74,17 +73,16 @@ char *prepbuf(faddr *addr)
* If we got a 5d address we use the given domain, if * If we got a 5d address we use the given domain, if
* we got a 4d address, we look for a matching domain name. * we got a 4d address, we look for a matching domain name.
*/ */
if (addr->domain) if (addr && addr->domain && strlen(addr->domain)) {
domain = xstrcpy(addr->domain); domain = xstrcpy(addr->domain);
else } else
for (i = 0; i < 40; i++) for (i = 0; i < 40; i++)
if (CFG.aka[i].zone == addr->zone) { if (CFG.aka[i].zone == addr->zone) {
domain = xstrcpy(CFG.aka[i].domain); domain = xstrcpy(CFG.aka[i].domain);
break; break;
} }
if ((domain != NULL) && (strlen(CFG.aka[0].domain) != 0) && if ((domain != NULL) && (strlen(CFG.aka[0].domain) != 0) && (strcasecmp(domain,CFG.aka[0].domain) != 0)) {
(strcasecmp(domain,CFG.aka[0].domain) != 0)) {
if ((p = strrchr(buf,'/'))) if ((p = strrchr(buf,'/')))
p++; p++;
else else
@ -93,8 +91,7 @@ char *prepbuf(faddr *addr)
for (; *p; p++) for (; *p; p++)
*p = tolower(*p); *p = tolower(*p);
for (i = 0; i < 40; i++) for (i = 0; i < 40; i++)
if ((strlen(CFG.aka[i].domain)) && if ((strlen(CFG.aka[i].domain)) && (strcasecmp(CFG.aka[i].domain, domain) == 0))
(strcasecmp(CFG.aka[i].domain, domain) == 0))
break; break;
/* /*
@ -124,99 +121,105 @@ char *prepbuf(faddr *addr)
else else
sprintf(p,"%s/%04x%04x.",zpref,addr->net,addr->node); sprintf(p,"%s/%04x%04x.",zpref,addr->net,addr->node);
p = buf + strlen(buf);
if (domain) if (domain)
free(domain); free(domain);
return p; return buf;
} }
char *pktname(faddr *addr, char flavor) char *pktname(faddr *addr, char flavor)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
if (flavor == 'f') if (flavor == 'f')
flavor = 'o'; flavor = 'o';
sprintf(p, "%c%s", flavor, ptyp); q = p + strlen(p);
Syslog('O', "packet name is \"%s\"",buf); sprintf(q, "%c%s", flavor, ptyp);
return buf; Syslog('O', "packet name is \"%s\"", p);
return p;
} }
char *floname(faddr *addr, char flavor) char *floname(faddr *addr, char flavor)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
if (flavor == 'o') if (flavor == 'o')
flavor = 'f'; flavor = 'f';
sprintf(p, "%c%s", flavor, ftyp); q = p + strlen(p);
Syslog('O', "flo file name is \"%s\"",buf); sprintf(q, "%c%s", flavor, ftyp);
return buf; Syslog('O', "flo file name is \"%s\"", p);
return p;
} }
char *reqname(faddr *addr) char *reqname(faddr *addr)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
sprintf(p, "%s", rtyp); q = p + strlen(p);
Syslog('O', "req file name is \"%s\"",buf); sprintf(q, "%s", rtyp);
return buf; Syslog('O', "req file name is \"%s\"", p);
return p;
} }
char *splname(faddr *addr) char *splname(faddr *addr)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
sprintf(p, "%s", styp); q = p + strlen(p);
Syslog('O', "spl file name is \"%s\"",buf); sprintf(q, "%s", styp);
return buf; Syslog('O', "spl file name is \"%s\"", p);
return p;
} }
char *bsyname(faddr *addr) char *bsyname(faddr *addr)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
sprintf(p, "%s", btyp); q = p + strlen(p);
Syslog('O', "bsy file name is \"%s\"",buf); sprintf(q, "%s", btyp);
return buf; Syslog('O', "bsy file name is \"%s\"", p);
return p;
} }
char *stsname(faddr *addr) char *stsname(faddr *addr)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
sprintf(p, "%s", qtyp); q = p + strlen(p);
Syslog('O', "sts file name is \"%s\"",buf); sprintf(q, "%s", qtyp);
return buf; Syslog('O', "sts file name is \"%s\"", p);
return p;
} }
char *polname(faddr *addr) char *polname(faddr *addr)
{ {
char *p; static char *p, *q;
p = prepbuf(addr); p = prepbuf(addr);
sprintf(p, "%s", ltyp); q = p + strlen(p);
Syslog('O', "pol file name is \"%s\"", buf); sprintf(q, "%s", ltyp);
return buf; Syslog('O', "pol file name is \"%s\"", p);
return p;
} }
@ -228,6 +231,7 @@ char *dayname(void)
{ {
time_t tt; time_t tt;
struct tm *ptm; struct tm *ptm;
static char buf[3];
tt = time(NULL); tt = time(NULL);
ptm = localtime(&tt); ptm = localtime(&tt);
@ -240,6 +244,7 @@ char *dayname(void)
char *arcname(faddr *addr, unsigned short Zone, int ARCmailCompat) char *arcname(faddr *addr, unsigned short Zone, int ARCmailCompat)
{ {
static char *buf;
char *p; char *p;
char *ext; char *ext;
time_t tt; time_t tt;
@ -252,7 +257,7 @@ char *arcname(faddr *addr, unsigned short Zone, int ARCmailCompat)
bestaka = bestaka_s(addr); bestaka = bestaka_s(addr);
(void)prepbuf(addr); buf = prepbuf(addr);
p = strrchr(buf, '/'); p = strrchr(buf, '/');
if (!ARCmailCompat && (Zone != addr->zone)) { if (!ARCmailCompat && (Zone != addr->zone)) {

View File

@ -127,18 +127,14 @@ void ulockprogram(char *progname)
free(lockfile); free(lockfile);
return; return;
} }
if (fscanf(fp, "%u", &oldpid) != 1) { if (fscanf(fp, "%u", &oldpid) != 1) {
WriteError("$Can't read old pid from \"%s\"", lockfile); WriteError("$Can't read old pid from \"%s\"", lockfile);
}
fclose(fp); fclose(fp);
unlink(lockfile); unlink(lockfile);
free(lockfile); free(lockfile);
return; lockfile = NULL;
}
if (oldpid == getpid()) {
(void)unlink(lockfile);
}
free(lockfile);
} }

View File

@ -136,7 +136,10 @@ void die(int onsig)
t_end = time(NULL); t_end = time(NULL);
Syslog(' ', "MBCICO finished in %s", t_elapsed(t_start, t_end)); Syslog(' ', "MBCICO finished in %s", t_elapsed(t_start, t_end));
free_mem(); free_mem();
deinitnl();
if (envptr) if (envptr)
free(envptr); free(envptr);
ExitClient(onsig); ExitClient(onsig);
@ -190,9 +193,9 @@ int main(int argc, char *argv[])
* Catch all signals we can, and ignore the rest. * Catch all signals we can, and ignore the rest.
*/ */
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL)) { if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) {
signal(i, (void (*))die); signal(i, (void (*))die);
} else { } else if ((i != SIGKILL) && (i != SIGSTOP)) {
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }
} }

View File

@ -43,6 +43,7 @@
#include "outstat.h" #include "outstat.h"
#include "nlinfo.h" #include "nlinfo.h"
extern int most_debug;
extern int do_quiet; /* Suppress screen output */ extern int do_quiet; /* Suppress screen output */
int do_attach = FALSE; /* Send file attaches */ int do_attach = FALSE; /* Send file attaches */
@ -179,6 +180,8 @@ int main(int argc, char *argv[])
FILE *fl; FILE *fl;
unsigned long cmmask; unsigned long cmmask;
most_debug = TRUE;
InitConfig(); InitConfig();
InitNode(); InitNode();
InitFidonet(); InitFidonet();

View File

@ -373,7 +373,7 @@ int poll(faddr *addr, int stop)
if (addr == NULL) if (addr == NULL)
return 0; return 0;
pol = polname(addr); pol = xstrcpy(polname(addr));
if (stop) { if (stop) {
if (access(pol, R_OK) == 0) { if (access(pol, R_OK) == 0) {
@ -393,18 +393,21 @@ int poll(faddr *addr, int stop)
Syslog('+', "Node %s not in nodelist", ascfnode(addr, 0x1f)); Syslog('+', "Node %s not in nodelist", ascfnode(addr, 0x1f));
if (!do_quiet) if (!do_quiet)
printf("Node %s not in nodelist", ascfnode(addr, 0x1f)); printf("Node %s not in nodelist", ascfnode(addr, 0x1f));
free(pol);
return MBERR_NODE_NOT_IN_LIST; return MBERR_NODE_NOT_IN_LIST;
} }
if (nlent->pflag == NL_DOWN) { if (nlent->pflag == NL_DOWN) {
Syslog('+', "Node %s has status Down", ascfnode(addr, 0x1f)); Syslog('+', "Node %s has status Down", ascfnode(addr, 0x1f));
if (!do_quiet) if (!do_quiet)
printf("Node %s has status Down", ascfnode(addr, 0x1f)); printf("Node %s has status Down", ascfnode(addr, 0x1f));
free(pol);
return MBERR_NODE_MAY_NOT_CALL; return MBERR_NODE_MAY_NOT_CALL;
} }
if (nlent->pflag == NL_HOLD) { if (nlent->pflag == NL_HOLD) {
Syslog('+', "Node %s has status Hold", ascfnode(addr, 0x1f)); Syslog('+', "Node %s has status Hold", ascfnode(addr, 0x1f));
if (!do_quiet) if (!do_quiet)
printf("Node %s has status Hold", ascfnode(addr, 0x1f)); printf("Node %s has status Hold", ascfnode(addr, 0x1f));
free(pol);
return MBERR_NODE_MAY_NOT_CALL; return MBERR_NODE_MAY_NOT_CALL;
} }
@ -438,6 +441,7 @@ int poll(faddr *addr, int stop)
} }
} }
free(pol);
return 0; return 0;
} }

View File

@ -215,6 +215,7 @@ int dirinbound(void)
} }
fseek(fp, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR); fseek(fp, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR);
} }
fclose(fp);
} }
free(temp); free(temp);
Syslog('m', "Finished directory inbound sessions"); Syslog('m', "Finished directory inbound sessions");

View File

@ -4,7 +4,7 @@
* Purpose ...............: Announce new files and FileFind * Purpose ...............: Announce new files and FileFind
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -112,7 +112,7 @@ int main(int argc, char **argv)
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -130,9 +130,9 @@ int main(int argc, char **argv)
* Catch all signals we can, and ignore the rest. * Catch all signals we can, and ignore the rest.
*/ */
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGKILL)) if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -202,6 +202,7 @@ void die(int onsig)
Msg_Close(); Msg_Close();
signal(onsig, SIG_IGN); signal(onsig, SIG_IGN);
deinitnl();
if (!do_quiet) { if (!do_quiet) {
show_log = TRUE; show_log = TRUE;
@ -320,9 +321,9 @@ int main(int argc, char **argv)
*/ */
for(i = 0; i < NSIG; i++) { for(i = 0; i < NSIG; i++) {
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL)) if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -88,9 +88,9 @@ int main(int argc, char **argv)
* Catch all signals we can, and ignore the rest. * Catch all signals we can, and ignore the rest.
*/ */
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGKILL) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -324,9 +324,9 @@ void closepage(FILE *fa, char *Path, int inArea, int Current, FILE *fi)
sprintf(temp2, "%s/index.temp", Path); sprintf(temp2, "%s/index.temp", Path);
} }
rename(temp2, temp1); rename(temp2, temp1);
chmod(temp1, 0644);
free(temp1); free(temp1);
free(temp2); free(temp2);
chmod(temp1, 0644);
fa = NULL; fa = NULL;
} }

View File

@ -154,7 +154,7 @@ int main(int argc,char *argv[])
if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV)) if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }
@ -581,6 +581,7 @@ int compile(char *nlname, unsigned short zo, unsigned short ne, unsigned short n
fill_nllist(ndx, &nll); fill_nllist(ndx, &nll);
} }
fclose(nl);
Syslog('+', "%d entries", entries); Syslog('+', "%d entries", entries);
if (!do_quiet) { if (!do_quiet) {

View File

@ -98,10 +98,9 @@ int main(int argc, char **argv)
* Catch all signals we can, and ignore or catch them * Catch all signals we can, and ignore or catch them
*/ */
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
(i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Netmail tracker / router * Purpose ...............: Netmail tracker / router
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -267,6 +267,7 @@ int IsLocal(char *ftn, fidoaddr *res)
} }
} }
tidy_faddr(dest);
return R_NOROUTE; return R_NOROUTE;
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Common utilities * Purpose ...............: Common utilities
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -208,8 +208,7 @@ void Nopper(void)
int socket_connect(char *user) int socket_connect(char *user)
{ {
int s; int s;
static char buf[SS_BUFSIZE]; static char buf[SS_BUFSIZE], tty[18];
char tty[18];
if ((s = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) { if ((s = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) {
perror("mbmon"); perror("mbmon");
@ -239,11 +238,11 @@ int socket_connect(char *user)
if (isatty(1) && (ttyname(1) != NULL)) { if (isatty(1) && (ttyname(1) != NULL)) {
strcpy(tty, ttyname(1)); strcpy(tty, ttyname(1));
if (strchr(tty, 'p')) if (strchr(tty, 'p'))
strcpy(tty, index(tty, 'p')); memccpy(tty, index(tty, 'p'), '\0', strlen(tty));
else if (strchr(tty, 't')) else if (strchr(tty, 't'))
strcpy(tty, index(tty, 't')); memccpy(tty, index(tty, 't'), '\0', strlen(tty));
else if (strchr(tty, 'c')) else if (strchr(tty, 'c'))
strcpy(tty, index(tty, 'c')); memccpy(tty, index(tty, 'c'), '\0', strlen(tty));
} else { } else {
strcpy(tty, "-"); strcpy(tty, "-");
} }

View File

@ -319,11 +319,8 @@ void system_stat(void)
void disk_stat(void) void disk_stat(void)
{ {
int ch, i; int ch, i;
char buf[1024]; char buf[1024], *cnt, *type, *fs, *p, sign;
char *cnt, *type, *fs, *p; unsigned long last[10], size, used, perc;
unsigned long last[10];
unsigned long size, used, perc;
char sign;
clr_index(); clr_index();
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
@ -333,6 +330,8 @@ void disk_stat(void)
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
mvprintw(lines - 2, 6, "Press any key"); mvprintw(lines - 2, 6, "Press any key");
IsDoing("Filesystem Usage"); IsDoing("Filesystem Usage");
for (i = 0; i < 10; i++)
last[i] = 0;
do { do {
show_date(LIGHTGRAY, BLACK, 0, 0); show_date(LIGHTGRAY, BLACK, 0, 0);
@ -361,8 +360,7 @@ void disk_stat(void)
sign = ' '; sign = ' ';
last[i] = used; last[i] = used;
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
mvprintw(i+8, 1, "%8lu %8lu ", mvprintw(i+8, 1, "%8lu %8lu ", size, used);
size, used);
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
printf("%c ", sign); printf("%c ", sign);
set_color(CYAN, BLACK); set_color(CYAN, BLACK);

View File

@ -130,6 +130,7 @@ void ulockprogram(char *progname)
free(lockfile); free(lockfile);
return; return;
} }
fclose(fp);
if (oldpid == getpid()) { if (oldpid == getpid()) {
(void)unlink(lockfile); (void)unlink(lockfile);

View File

@ -145,9 +145,9 @@ int main(int argc, char **argv)
* Catch all signals we can, and ignore the rest. * Catch all signals we can, and ignore the rest.
*/ */
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGKILL) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }
@ -324,6 +324,7 @@ void Masterlist()
fprintf(fp, "%s\r\n", temp); fprintf(fp, "%s\r\n", temp);
fprintf(np, "%s\r\n", temp); fprintf(np, "%s\r\n", temp);
} }
fclose(pHeader);
} }
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
@ -457,6 +458,7 @@ void Masterlist()
fprintf(fp, "%s\r\n", temp); fprintf(fp, "%s\r\n", temp);
fprintf(np, "%s\r\n", temp); fprintf(np, "%s\r\n", temp);
} }
fclose(pHeader);
} }
fclose(fp); fclose(fp);
@ -505,6 +507,7 @@ void MakeArc()
(char *)"/dev/null", (char *)"/dev/null") == 0) (char *)"/dev/null", (char *)"/dev/null") == 0)
WriteError("Create newfiles.zip failed"); WriteError("Create newfiles.zip failed");
free(cmd); free(cmd);
cmd = NULL;
} }

View File

@ -125,6 +125,7 @@ int main(int argc, char **argv)
if ((tty = ttyname(0)) == NULL) { if ((tty = ttyname(0)) == NULL) {
WriteError("Not at a tty"); WriteError("Not at a tty");
Free_Language();
Quick_Bye(MBERR_OK); Quick_Bye(MBERR_OK);
} }
@ -160,6 +161,7 @@ int main(int argc, char **argv)
*/ */
if (CheckStatus() == FALSE) { if (CheckStatus() == FALSE) {
Syslog('+', "Kicking user out, the BBS is closed"); Syslog('+', "Kicking user out, the BBS is closed");
Free_Language();
Quick_Bye(MBERR_OK); Quick_Bye(MBERR_OK);
} }
@ -192,6 +194,7 @@ int main(int argc, char **argv)
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) { if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY); Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
printf("No BBS on this port allowed!\n\n"); printf("No BBS on this port allowed!\n\n");
Free_Language();
Quick_Bye(MBERR_OK); Quick_Bye(MBERR_OK);
} }

View File

@ -122,7 +122,7 @@ int main(int argc, char **argv)
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -387,7 +387,10 @@ void UserPack(int days, int level, int pack)
fclose(fout); fclose(fout);
chmod(fnin, 0660); chmod(fnin, 0660);
Syslog('+', "Userbase is updated, written %d records", record); Syslog('+', "Userbase is updated, written %d records", record);
} else {
fclose(fout);
} }
unlink(fnout); unlink(fnout);
free(fnin); free(fnin);
free(fnout); free(fnout);

View File

@ -211,6 +211,7 @@ void user()
printf("%s\n", (char *) Language(390)); printf("%s\n", (char *) Language(390));
Syslog('?', "FATAL: Could not find user in BBS users file."); Syslog('?', "FATAL: Could not find user in BBS users file.");
Syslog('?', " and system is using unix accounts\n"); Syslog('?', " and system is using unix accounts\n");
Free_Language();
ExitClient(MBERR_OK); ExitClient(MBERR_OK);
} }

View File

@ -465,7 +465,7 @@ void gold_akamatch(FILE *fp)
{ {
char temp[PATH_MAX]; char temp[PATH_MAX];
FILE *fido; FILE *fido;
faddr *want; faddr *want, *ta;
int i; int i;
sprintf(temp, "%s/etc/fidonet.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/fidonet.data", getenv("MBSE_ROOT"));
@ -486,14 +486,16 @@ void gold_akamatch(FILE *fp)
want->point = 0; want->point = 0;
want->name = NULL; want->name = NULL;
want->domain = NULL; want->domain = NULL;
fprintf(fp, "AKAMATCH %d:* %s\n", fidonet.zone[i], ascfnode(bestaka_s(want), 0xf)); ta = bestaka_s(want);
fprintf(fp, "AKAMATCH %d:* %s\n", fidonet.zone[i], ascfnode(ta, 0xf));
tidy_faddr(ta);
} }
} }
free(want); free(want);
fprintf(fp, ";\n"); fprintf(fp, ";\n");
fprintf(fp, "AKAMATCHNET YES\n"); fprintf(fp, "AKAMATCHNET YES\n");
fprintf(fp, "AKAMATCHECHO YES\n"); /* On request, should work better */ fprintf(fp, "AKAMATCHECHO YES\n");
fprintf(fp, "AKAMATCHLOCAL NO\n\n"); fprintf(fp, "AKAMATCHLOCAL NO\n\n");
fprintf(fp, "; NODELISTS\n;\n"); fprintf(fp, "; NODELISTS\n;\n");

View File

@ -779,7 +779,7 @@ void s_fidomailcfg(void)
mvprintw(12,42, "13. 4d address"); mvprintw(12,42, "13. 4d address");
mvprintw(13,42, "14. Split at"); mvprintw(13,42, "14. Split at");
mvprintw(14,42, "15. Force at"); mvprintw(14,42, "15. Force at");
mvprintw(15,42, "16. Allow %+*"); mvprintw(15,42, "16. Allow +*");
mvprintw(16,42, "17. Notify"); mvprintw(16,42, "17. Notify");
mvprintw(17,42, "18. Passwd"); mvprintw(17,42, "18. Passwd");
mvprintw(18,42, "19. Pause"); mvprintw(18,42, "19. Pause");

View File

@ -4,7 +4,7 @@
* Purpose ...............: Message Areas Setup * Purpose ...............: Message Areas Setup
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -714,7 +714,8 @@ void MsgGlobal(void)
menu = select_menu(13); menu = select_menu(13);
switch (menu) { switch (menu) {
case 0: return; case 0: tidy_grlist(&mgr);
return;
case 1: a1 = PullUplink((char *)"AKA TO DELETE"); case 1: a1 = PullUplink((char *)"AKA TO DELETE");
break; break;
case 2: a2 = PullUplink((char *)"AKA TO ADD"); case 2: a2 = PullUplink((char *)"AKA TO ADD");
@ -991,6 +992,7 @@ void MsgGlobal(void)
} }
if (tfil != NULL) if (tfil != NULL)
fclose(tfil); fclose(tfil);
tfil = NULL;
} }
working(0, 0, 0); working(0, 0, 0);
@ -1099,6 +1101,9 @@ int EditMsgRec(int Area)
Syslog('+', "Saved message area record %d", Area); Syslog('+', "Saved message area record %d", Area);
} }
} }
if (tfil != NULL)
fclose(tfil);
tfil = NULL;
IsDoing("Browsing Menu"); IsDoing("Browsing Menu");
return 0; return 0;
case 1: E_STR( 6,16,40,msgs.Name, "The ^Name^ of this area") case 1: E_STR( 6,16,40,msgs.Name, "The ^Name^ of this area")

View File

@ -270,10 +270,10 @@ void CloseNoderec(int Force)
} }
chmod(fin, 0640); chmod(fin, 0640);
unlink(fout);
working(1, 0, 0); working(1, 0, 0);
free(fin); free(fin);
free(fout); free(fout);
unlink(fout);
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: TIC Areas Setup Program * Purpose ...............: TIC Areas Setup Program
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -611,7 +611,8 @@ void TicGlobal(void)
menu = select_menu(7); menu = select_menu(7);
switch (menu) { switch (menu) {
case 0: return; case 0: tidy_grlist(&mgr);
return;
case 1: a1 = PullUplink((char *)"AKA TO DELETE"); case 1: a1 = PullUplink((char *)"AKA TO DELETE");
break; break;
case 2: a2 = PullUplink((char *)"AKA TO ADD"); case 2: a2 = PullUplink((char *)"AKA TO ADD");
@ -900,6 +901,9 @@ int EditTicRec(int Area)
Syslog('+', "Saved tic record %d", Area); Syslog('+', "Saved tic record %d", Area);
} }
} }
if (ttfil != NULL)
fclose(ttfil);
ttfil = NULL;
IsDoing("Browsing Menu"); IsDoing("Browsing Menu");
free(temp); free(temp);
return 0; return 0;

View File

@ -24,7 +24,7 @@ OTHER = Makefile issue issue.netbsd
all: mbtask all: mbtask
mbtask: ${OBJS} ${LIBS} mbtask: ${OBJS} ${LIBS}
${CC} -o mbtask ${OBJS} ${LIBS} ${CC} -o mbtask ${OBJS} ${PTLIBS} ${LIBS}
clean: clean:
rm -f mbtask *.o *.h~ *.c~ version.* core filelist Makefile.bak rm -f mbtask *.o *.h~ *.c~ version.* core filelist Makefile.bak

View File

@ -5,7 +5,7 @@
* Shadow Suite (c) ......: Julianne Frances Haugh * Shadow Suite (c) ......: Julianne Frances Haugh
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -759,10 +759,12 @@ int main(int argc, char *argv[])
gr = getgrgid(pw->pw_gid); gr = getgrgid(pw->pw_gid);
if (!gr) { if (!gr) {
fprintf(stderr, "mbpasswd: Cannot determine group name.\n"); fprintf(stderr, "mbpasswd: Cannot determine group name.\n");
free(myname);
exit(E_NOPERM); exit(E_NOPERM);
} }
if (strcmp(gr->gr_name, (char *)"bbs")) { if (strcmp(gr->gr_name, (char *)"bbs")) {
fprintf(stderr, "mbpasswd: You are not a member of group \"bbs\".\n"); fprintf(stderr, "mbpasswd: You are not a member of group \"bbs\".\n");
free(myname);
exit(E_NOPERM); exit(E_NOPERM);
} }
@ -776,6 +778,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "mbpasswd [-opt] [username] [newpassword]\n"); fprintf(stderr, "mbpasswd [-opt] [username] [newpassword]\n");
fprintf(stderr, "options are: -n normal password change\n"); fprintf(stderr, "options are: -n normal password change\n");
fprintf(stderr, " -f forced password change\n"); fprintf(stderr, " -f forced password change\n");
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
@ -787,6 +790,7 @@ int main(int argc, char *argv[])
force = 1; force = 1;
if (strcmp(pw->pw_name, (char *)"mbse") && strcmp(pw->pw_name, (char *)"bbs")) { if (strcmp(pw->pw_name, (char *)"mbse") && strcmp(pw->pw_name, (char *)"bbs")) {
fprintf(stderr, "mbpasswd: only users `mbse' and `bbs' may do this.\n"); fprintf(stderr, "mbpasswd: only users `mbse' and `bbs' may do this.\n");
free(myname);
exit(E_NOPERM); exit(E_NOPERM);
} }
} else if (strncmp(argv[1], "-n", 2) == 0) { } else if (strncmp(argv[1], "-n", 2) == 0) {
@ -797,10 +801,12 @@ int main(int argc, char *argv[])
force = 0; force = 0;
if (strcmp(pw->pw_name, argv[2])) { if (strcmp(pw->pw_name, argv[2])) {
fprintf(stderr, "mbpasswd: only owner may do this.\n"); fprintf(stderr, "mbpasswd: only owner may do this.\n");
free(myname);
exit(E_NOPERM); exit(E_NOPERM);
} }
} else { } else {
fprintf(stderr, "mbpasswd: wrong option switch.\n"); fprintf(stderr, "mbpasswd: wrong option switch.\n");
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
@ -809,10 +815,12 @@ int main(int argc, char *argv[])
*/ */
if (strlen(argv[2]) > 16) { if (strlen(argv[2]) > 16) {
fprintf(stderr, "mbpasswd: Username too long\n"); fprintf(stderr, "mbpasswd: Username too long\n");
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
if (strlen(argv[3]) > 16) { if (strlen(argv[3]) > 16) {
fprintf(stderr, "mbpasswd: Password too long\n"); fprintf(stderr, "mbpasswd: Password too long\n");
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
@ -826,6 +834,7 @@ int main(int argc, char *argv[])
if ((pw = getpwnam(name)) == NULL) { if ((pw = getpwnam(name)) == NULL) {
syslog(LOG_ERR, "mbpasswd: Unknown user %s", name); syslog(LOG_ERR, "mbpasswd: Unknown user %s", name);
fprintf(stderr, "mbpasswd: Unknown user %s\n", name); fprintf(stderr, "mbpasswd: Unknown user %s\n", name);
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
@ -855,6 +864,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "The password for %s is unchanged.\n", name); fprintf(stderr, "The password for %s is unchanged.\n", name);
syslog(LOG_ERR, "The password for %s is unchanged", name); syslog(LOG_ERR, "The password for %s is unchanged", name);
closelog(); closelog();
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
do_update_pwd = 1; do_update_pwd = 1;
@ -876,6 +886,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Cannot change ID to root.\n"); fprintf(stderr, "Cannot change ID to root.\n");
syslog(LOG_ERR, "can't setuid(0)"); syslog(LOG_ERR, "can't setuid(0)");
closelog(); closelog();
free(myname);
exit(E_FAILURE); exit(E_FAILURE);
} }
@ -927,6 +938,7 @@ int main(int argc, char *argv[])
syslog(LOG_NOTICE, "password for `%s' changed by user `%s'", name, myname); syslog(LOG_NOTICE, "password for `%s' changed by user `%s'", name, myname);
closelog(); closelog();
free(myname);
exit(E_SUCCESS); exit(E_SUCCESS);
} }