From 2af1d25bdfc90c897f7cfad7663810ed0464ef64 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 16 Jun 2002 08:58:53 +0000 Subject: [PATCH] binkp start for CRC support --- ChangeLog | 2 ++ TODO | 3 +++ mbcico/binkp.c | 26 ++++++++++++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c212144..5e1d23d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ v0.35.01 05-Jun-2002 mbcico: Now uses the new session password field for session handshake. The binkd version string now includes the OS and CPU type. + If a transmitted file via binkp is skipped by the remote it + will stay in the queue for the next session. mbfile: Added -v commandline switch to supress virus checking for the diff --git a/TODO b/TODO index bab29c12..f5c1609d 100644 --- a/TODO +++ b/TODO @@ -143,3 +143,6 @@ mbsetup: Fileecho groups <=> Newfile reports Fileecho groups <=> BBS Areas +install: + U: On RedHat 7.3 the big-endian menus are installed. + diff --git a/mbcico/binkp.c b/mbcico/binkp.c index d0727a98..8680ae7d 100644 --- a/mbcico/binkp.c +++ b/mbcico/binkp.c @@ -84,6 +84,7 @@ static int MBflag = FALSE; static int NDflag = FALSE; static int CRYPTflag = FALSE; static int CRAMflag = FALSE; +static int CRCflag = FALSE; unsigned long nethold, mailhold; int transferred = FALSE; int batchnr = 0; @@ -368,9 +369,10 @@ void b_nul(char *msg) NDflag = TRUE; if (strstr(msg, (char *)"CRYPT") != NULL) CRYPTflag = TRUE; - if (strstr(msg, (char *)"CRAM-") != NULL) { + if (strstr(msg, (char *)"CRAM-") != NULL) CRAMflag = TRUE; - } + if (strstr(msg, (char *)"CRC") != NULL) + CRCflag = TRUE; } else Syslog('+', "M_NUL \"%s\"", msg); } @@ -799,7 +801,7 @@ int binkp_batch(file_list *to_send) int sverr, cmd = FALSE, GotFrame = FALSE; int blklen = 0, c, Found = FALSE; unsigned short header = 0; - char *rname, *lname, *gname; + char *rname, *lname, *gname, *rcrc; long rsize, roffs, lsize, gsize, goffset; time_t rtime, ltime, gtime; off_t rxbytes; @@ -821,6 +823,7 @@ int binkp_batch(file_list *to_send) txbuf = calloc(MAX_BLKSIZE + 3, sizeof(unsigned char)); rxbuf = calloc(MAX_BLKSIZE + 3, sizeof(unsigned char)); rname = calloc(512, sizeof(char)); + rcrc = calloc(512, sizeof(char)); lname = calloc(512, sizeof(char)); gname = calloc(512, sizeof(char)); TfState = Switch; @@ -1090,7 +1093,18 @@ int binkp_batch(file_list *to_send) case MM_FILE: if ((RxState == RxWaitFile) || (RxState == RxEndOfBatch)) { RxState = RxAcceptFile; - sscanf(rxbuf+1, "%s %ld %ld %ld", rname, &rsize, &rtime, &roffs); + Syslog('b', "MM_FILE %s", rxbuf+1); + if (strlen(rxbuf) < 512) { + /* + * Check against buffer overflow + */ + if (CRCflag) + sscanf(rxbuf+1, "%s %ld %ld %ld %s", rname, &rsize, &rtime, &roffs, rcrc); + else + sscanf(rxbuf+1, "%s %ld %ld %ld", rname, &rsize, &rtime, &roffs); + } else { + Syslog('+', "Got corrupted FILE frame, size %d bytes", strlen(rxbuf)); + } } else { Syslog('+', "Binkp: got unexpected FILE frame %s", rxbuf+1); } @@ -1190,8 +1204,7 @@ int binkp_batch(file_list *to_send) execute_disposition(tsl); } else { for (tmp = bll; tmp; tmp = tmp->next) { - if ((strcmp(tmp->local, tsl->local) == 0) && - ((tmp->state == Got) || (tmp->state == Skipped))) { + if ((strcmp(tmp->local, tsl->local) == 0) && (tmp->state == Got)) { execute_disposition(tsl); } } @@ -1210,6 +1223,7 @@ int binkp_batch(file_list *to_send) free(txbuf); free(rxbuf); free(rname); + free(rcrc); free(lname); free(gname); Syslog('+', "Binkp: batch %d completed rc=%d", batchnr, rc);