More small code/leak fixes

This commit is contained in:
Michiel Broek 2003-12-07 11:54:05 +00:00
parent f7b6706f5a
commit 0bd46be230
5 changed files with 18 additions and 29 deletions

View File

@ -20,7 +20,7 @@ v0.39.3 26-Nov-2003
by valgrind.
libcommon:
Code cleanup in proglock and pktname.
Code cleanup in proglock, pktname and crc.
Fixed a forgotten fclose in proglock.
libmsgbase:

2
TODO
View File

@ -117,8 +117,6 @@ mbfido:
N: Tic, scan tests with valgrind.
mbcico:
N: Test with valgrind, binkp, raw ifcico with tcp proto is ok.
N: Upgrade binkp protocol to 1.1.
N: With binkp, if the other node is a binkp/1.0 mailer without MB

View File

@ -1,11 +1,11 @@
/*****************************************************************************
*
* $Id$
* File ..................: crc.c
* Purpose ...............: Crc32 and Crc16 calculations
* Last modification date : 18-Mar-2000
*
*****************************************************************************
* Copyright (C) 1993-2000
* Copyright (C) 1993-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -188,7 +188,7 @@ unsigned long crc32ccitt(char *str, int l)
unsigned long crc;
for (crc = 0xffffffffL; l--; str++)
crc = crc32tab[((int) crc ^ (*str)) & 0xff] ^ ((crc >> 8) & 0x00ffffff);
crc = crc32tab[((int) crc ^ (*str)) & 0xff] ^ ((crc >> 8) & 0x00ffffffL);
return crc;
}
@ -216,7 +216,7 @@ unsigned long str_crc32(char *str)
unsigned long crc;
for (crc=0L; *str; str++)
crc = crc32tab[((int)crc^(*str)) & 0xff] ^ ((crc>>8) & 0x00ffffff);
crc = crc32tab[((int)crc^(*str)) & 0xff] ^ ((crc>>8) & 0x00ffffffL);
return crc;
}
@ -226,24 +226,13 @@ unsigned long StringCRC32(char *str)
{
unsigned long crc;
for (crc = 0xffffffff; *str; str++)
crc = crc32tab[((int)crc^(*str)) & 0xff] ^ ((crc>>8) & 0x00ffffff);
for (crc = 0xffffffffL; *str; str++)
crc = crc32tab[((int)crc^(*str)) & 0xff] ^ ((crc>>8) & 0x00ffffffL);
return crc;
}
/*
* Update CRC32, first initialize CRC with 0xffffffff.
*/
/*
unsigned long update_crc32(int octet, unsigned long crc)
{
return (crc32tab[((int)crc ^ ((long)octet)) & 0xff] ^ ((((unsigned long)crc) >> 8) & 0x00ffffff));
}
*/
/*
* Update CRC32, first initialize crc with 0xffffffff
*/
@ -254,7 +243,7 @@ unsigned long upd_crc32(char *buf, unsigned long crc, int len)
cr = crc;
for (i = 0; i < len; i++) {
cr = (crc32tab[((int)cr ^ ((long)buf[i])) & 0xff] ^ ((((unsigned long)cr) >> 8) & 0x00ffffff));
cr = (crc32tab[((int)cr ^ ((long)buf[i])) & 0xff] ^ ((((unsigned long)cr) >> 8) & 0x00ffffffL));
}
return cr;
}
@ -269,13 +258,13 @@ unsigned long norm_crc32(unsigned long crc)
{
unsigned long L;
L = crc & 0x000000ff;
L = crc & 0x000000ffL;
L <<= 8;
L |= ((crc >> 8) & 0x000000ff);
L |= ((crc >> 8) & 0x000000ffL);
L <<= 8;
L |= ((crc >> 16) & 0x000000ff);
L |= ((crc >> 16) & 0x000000ffL);
L <<= 8;
L |= ((crc >> 24) & 0x000000ff);
L |= ((crc >> 24) & 0x000000ffL);
return L;
}

View File

@ -125,7 +125,9 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
}
tidy_faddr(ta);
}
if (msgid)
free(msgid);
msgid = NULL;
}
if (!strncmp(buf, "\001FMPT", 5)) {
p = strtok(buf, " \n");

View File

@ -4,7 +4,7 @@
* Purpose ...............: Import a netmail message in the message base.
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -133,11 +133,11 @@ int storenet(faddr *f, faddr *t, time_t mdate, int flags, char *Subj, char *msgi
* Set MSGID and REPLY crc.
*/
if (msgid != NULL) {
crc2 = -1;
crc2 = 0xffffffffL;
Msg.MsgIdCRC = upd_crc32(msgid, crc2, strlen(msgid));
}
if (reply != NULL) {
crc2 = -1;
crc2 = 0xffffffffL;
Msg.ReplyCRC = upd_crc32(reply, crc2, strlen(reply));
}