- [bufaux.c] save a view malloc/memcpy/memset/free's, ok niels
- [scp.c] fix overflow reported by damien@ibs.com.au: off_t
totalsize, ok niels,aaron
bits = GET_16BIT(buf);
/* Compute the number of binary bytes that follow. */
bytes = (bits + 7) / 8;
- bin = xmalloc(bytes);
- buffer_get(buffer, bin, bytes);
+ if (buffer_len(buffer) < bytes)
+ fatal("buffer_get_bignum: input buffer too small");
+ bin = buffer_ptr(buffer);
BN_bin2bn(bin, bytes, value);
- xfree(bin);
+ buffer_consume(buffer, bytes);
return 2 + bytes;
}
volatile unsigned long statbytes;
/* Total size of current file. */
-unsigned long totalbytes = 0;
+off_t totalbytes = 0;
/* Name of current file being transferred. */
char *curfile;
}
(void)gettimeofday(&now, (struct timezone *)0);
cursize = statbytes;
- if ((totalbytes >> 10) != 0) {
- ratio = (cursize >> 10) * 100 / (totalbytes >> 10);
+ if (totalbytes != 0) {
+ ratio = cursize * 100 / totalbytes;
ratio = MAX(ratio, 0);
ratio = MIN(ratio, 100);
}