Bug#452789: xxd segfaults with large values for -c
Bram Moolenaar
Bram at moolenaar.net
Thu Nov 29 20:19:10 UTC 2007
James -
> On Wed, Nov 28, 2007 at 09:19:46AM -0500, James Vega wrote:
> > On Tue, Nov 27, 2007 at 10:26:31PM +0100, Bram Moolenaar wrote:
> > > I'm not the maintainer of xxd, but since it's included with Vim I tried
> > > fixing it anyway. Please try the patch below and check that it fixes
> > > the problem for you.
> >
> > That does work. Thanks.
>
> Actually, I was incorrect. I still see crashes when using values larger
> than 140 for -c. The following was from running
> "xxd -b -c 145 /usr/bin/xxd".
Hmm, I still underestimated the size of the array needed for the bitwise
display. Try this new diff:
*** ../vim-7.1.163/src/xxd/xxd.c Thu May 10 19:07:42 2007
--- src/xxd/xxd.c Thu Nov 29 21:05:16 2007
***************
*** 212,218 ****
#define TRY_SEEK /* attempt to use lseek, or skip forward by reading */
#define COLS 256 /* change here, if you ever need more columns */
! #define LLEN (9 + (5*COLS-1)/2 + 2 + COLS)
char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
--- 212,218 ----
#define TRY_SEEK /* attempt to use lseek, or skip forward by reading */
#define COLS 256 /* change here, if you ever need more columns */
! #define LLEN (11 + (9*COLS-1)/1 + COLS + 2)
char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
***************
*** 590,596 ****
default: octspergrp = 0; break;
}
! if (cols < 1 || (!hextype && (cols > COLS)))
{
fprintf(stderr, "%s: invalid number of columns (max. %d).\n", pname, COLS);
exit(1);
--- 590,597 ----
default: octspergrp = 0; break;
}
! if (cols < 1 || ((hextype == HEX_NORMAL || hextype == HEX_BITS)
! && (cols > COLS)))
{
fprintf(stderr, "%s: invalid number of columns (max. %d).\n", pname, COLS);
exit(1);
***************
*** 750,755 ****
--- 751,757 ----
}
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
+ /* When changing this update definition of LLEN above. */
l[11 + (grplen * cols - 1)/octspergrp + p] =
#ifdef __MVS__
(e >= 64)
--
hundred-and-one symptoms of being an internet addict:
160. You get in the elevator and double-click the button for the floor
you want.
/// Bram Moolenaar -- Bram at Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
More information about the pkg-vim-maintainers
mailing list