X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=rmt%2Frmt.c;h=3bd6207406336874a960410a365583ecc597eed2;hp=3167e1dd76e1f4015ccf83af6d26a763a28b7e0f;hb=e2392789784483d5c142443388c1a0bf8508592b;hpb=5bf65105dbaf0bb3d6fb4ccb3d8790bda496d861 diff --git a/rmt/rmt.c b/rmt/rmt.c index 3167e1d..3bd6207 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -18,11 +18,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: rmt.c,v 1.22 2003/01/10 14:42:51 stelian Exp $"; + "$Id: rmt.c,v 1.25 2003/03/31 10:09:41 stelian Exp $"; #endif /* not linux */ /* @@ -122,7 +118,7 @@ void getstring __P((char *)); int main(int argc, char *argv[]) { - int rval = 0; + OFF_T rval = 0; char c; int n, i, cc, oflags; unsigned long block = 0; @@ -191,6 +187,8 @@ top: case 'W': getstring(count); n = atoi(count); + if (n < 1) + exit(2); DEBUG2("rmtd: W %s (block = %lu)\n", count, block); record = checkbuf(record, n); for (i = 0; i < n; i += cc) { @@ -214,7 +212,7 @@ top: rval = read(tape, record, n); if (rval < 0) goto ioerror; - (void)sprintf(resp, "A%d\n", rval); + (void)sprintf(resp, "A%lld\n", (long long)rval); (void)write(1, resp, strlen(resp)); (void)write(1, record, rval); block += n >> 10; @@ -347,7 +345,7 @@ top: if (ioctl(tape, MTIOCGET, (char *)&mtget) < 0) goto ioerror; rval = sizeof (mtget); - (void)sprintf(resp, "A%d\n", rval); + (void)sprintf(resp, "A%lld\n", (long long)rval); (void)write(1, resp, strlen(resp)); (void)write(1, (char *)&mtget, sizeof (mtget)); goto top; @@ -407,8 +405,8 @@ top: exit(3); } respond: - DEBUG1("rmtd: A %d\n", rval); - (void)sprintf(resp, "A%d\n", rval); + DEBUG1("rmtd: A %lld\n", (long long)rval); + (void)sprintf(resp, "A%lld\n", (long long)rval); (void)write(1, resp, strlen(resp)); goto top; ioerror: @@ -421,7 +419,7 @@ void getstring(char *bp) int i; char *cp = bp; - for (i = 0; i < SSIZE; i++) { + for (i = 0; i < SSIZE - 1; i++) { if (read(0, cp+i, 1) != 1) exit(0); if (cp[i] == '\n')