=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tftp/tftpsubs.c,v retrieving revision 1.10 retrieving revision 1.11 diff -c -r1.10 -r1.11 *** src/usr.bin/tftp/tftpsubs.c 2006/07/12 16:58:51 1.10 --- src/usr.bin/tftp/tftpsubs.c 2006/07/20 09:42:44 1.11 *************** *** 1,4 **** ! /* $OpenBSD: tftpsubs.c,v 1.10 2006/07/12 16:58:51 mglocker Exp $ */ /* $NetBSD: tftpsubs.c,v 1.3 1994/12/08 09:51:31 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: tftpsubs.c,v 1.11 2006/07/20 09:42:44 mglocker Exp $ */ /* $NetBSD: tftpsubs.c,v 1.3 1994/12/08 09:51:31 jtc Exp $ */ /* *************** *** 35,41 **** static char sccsid[] = "@(#)tftpsubs.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = ! "$OpenBSD: tftpsubs.c,v 1.10 2006/07/12 16:58:51 mglocker Exp $"; #endif /* not lint */ /* --- 35,41 ---- static char sccsid[] = "@(#)tftpsubs.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = ! "$OpenBSD: tftpsubs.c,v 1.11 2006/07/20 09:42:44 mglocker Exp $"; #endif /* not lint */ /* *************** *** 62,68 **** #include "tftpsubs.h" - #define PKTSIZE SEGSIZE + 4 /* should be moved to tftp.h */ /* values for bf.counter */ #define BF_ALLOC -3 /* alloc'd but not yet filled */ #define BF_FREE -2 /* free */ --- 62,67 ---- *************** *** 71,78 **** static struct tftphdr *rw_init(int); struct bf { ! int counter; /* size of data in buffer, or flag */ ! char buf[PKTSIZE]; /* room for data packet */ } bfs[2]; static int nextone; /* index of next buffer to use */ --- 70,77 ---- static struct tftphdr *rw_init(int); struct bf { ! int counter; /* size of data in buffer, or flag */ ! char buf[SEGSIZE_MAX + 4]; /* room for data packet */ } bfs[2]; static int nextone; /* index of next buffer to use */ *************** *** 115,121 **** * Free it and return next buffer filled with data. */ int ! readit(FILE *file, struct tftphdr **dpp, int convert) { struct bf *b; --- 114,120 ---- * Free it and return next buffer filled with data. */ int ! readit(FILE *file, struct tftphdr **dpp, int convert, int segment_size) { struct bf *b; *************** *** 124,130 **** b = &bfs[current]; /* look at new buffer */ if (b->counter == BF_FREE) /* if it's empty */ ! read_ahead(file, convert); /* fill it */ /* assert(b->counter != BF_FREE); */ /* check */ *dpp = (struct tftphdr *)b->buf; /* set caller's ptr */ --- 123,129 ---- b = &bfs[current]; /* look at new buffer */ if (b->counter == BF_FREE) /* if it's empty */ ! read_ahead(file, convert, segment_size); /* fill it */ /* assert(b->counter != BF_FREE); */ /* check */ *dpp = (struct tftphdr *)b->buf; /* set caller's ptr */ *************** *** 136,142 **** * Conversions are lf -> cr, lf and cr -> cr, nul. */ void ! read_ahead(FILE *file, int convert) { int i; char *p; --- 135,141 ---- * Conversions are lf -> cr, lf and cr -> cr, nul. */ void ! read_ahead(FILE *file, int convert, int segment_size) { int i; char *p; *************** *** 152,163 **** dp = (struct tftphdr *)b->buf; if (convert == 0) { ! b->counter = read(fileno(file), dp->th_data, SEGSIZE); return; } p = dp->th_data; ! for (i = 0; i < SEGSIZE; i++) { if (newline) { if (prevchar == '\n') c = '\n'; /* lf to cr, lf */ --- 151,162 ---- dp = (struct tftphdr *)b->buf; if (convert == 0) { ! b->counter = read(fileno(file), dp->th_data, segment_size); return; } p = dp->th_data; ! for (i = 0; i < segment_size; i++) { if (newline) { if (prevchar == '\n') c = '\n'; /* lf to cr, lf */ *************** *** 266,272 **** synchnet(int f) { int i, j = 0; ! char rbuf[PKTSIZE]; struct sockaddr_in from; socklen_t fromlen; --- 265,271 ---- synchnet(int f) { int i, j = 0; ! char rbuf[SEGSIZE_MIN]; struct sockaddr_in from; socklen_t fromlen;