From 671eac8e2dca6a796b809fcf009118cc98d68d8f Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Fri, 5 Oct 2012 11:48:50 +0000 Subject: Aleph: Avoid segmentation fault for missing ocps git-svn-id: svn://tug.org/texlive/trunk@27884 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/alephdir/ChangeLog | 9 ++++++ Build/source/texk/web2c/alephdir/aleph.c | 44 ++++++++++++++---------------- Build/source/texk/web2c/alephdir/omocp.ch | 16 +++++++++-- 3 files changed, 42 insertions(+), 27 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/web2c/alephdir/ChangeLog b/Build/source/texk/web2c/alephdir/ChangeLog index 3e8c09c8d2b..c8017bc61db 100644 --- a/Build/source/texk/web2c/alephdir/ChangeLog +++ b/Build/source/texk/web2c/alephdir/ChangeLog @@ -1,3 +1,12 @@ +2012-10-05 Peter Breitenlohner + + * aleph.c ({allocate,undump}{font,ocp}table): Correctly specify + the new size for xrealloc(). Remove useless casts. + ({allocate,{un,}dump}fontsorttable): Drop unused functions. + * omocp.ch: Fix the logic of read_ocp_info(). + Check for ocp table overflow. + Avoid segmentation fault (uninitialized use of 'f'). + 2012-07-15 Akira Kakuto * alephextra.c: Must #define DLLPROC before reading alephd.h. diff --git a/Build/source/texk/web2c/alephdir/aleph.c b/Build/source/texk/web2c/alephdir/aleph.c index 315f9ad4cd4..7048dec4620 100644 --- a/Build/source/texk/web2c/alephdir/aleph.c +++ b/Build/source/texk/web2c/alephdir/aleph.c @@ -335,14 +335,13 @@ allocatefonttable (int font_number, int font_size) { int i; if (font_entries==0) { - fonttables = (memoryword **) xmalloc(256*sizeof(memoryword**)); + fonttables = xmalloc(256*sizeof(memoryword*)); font_entries=256; } else if ((font_number==256)&&(font_entries==256)) { - fonttables = xrealloc(fonttables, 65536); + fonttables = xrealloc(fonttables, 65536*sizeof(memoryword*)); font_entries=65536; } - fonttables[font_number] = - (memoryword *) xmalloc((font_size+1)*sizeof(memoryword)); + fonttables[font_number] = xmalloc((font_size+1)*sizeof(memoryword)); fonttables[font_number][0].cint = font_size; fonttables[font_number][0].cint1 = 0; for (i=1; i<=font_size; i++) { @@ -363,20 +362,20 @@ undumpfonttable(int font_number) { memoryword sizeword; if (font_entries==0) { - fonttables = (memoryword **) xmalloc(256*sizeof(memoryword**)); + fonttables = xmalloc(256*sizeof(memoryword*)); font_entries=256; } else if ((font_number==256)&&(font_entries==256)) { - fonttables = xrealloc(fonttables, 65536); + fonttables = xrealloc(fonttables, 65536*sizeof(memoryword*)); font_entries=65536; } undumpthings(sizeword,1); - fonttables[font_number] = - (memoryword *) xmalloc((sizeword.cint+1)*sizeof(memoryword)); + fonttables[font_number] = xmalloc((sizeword.cint+1)*sizeof(memoryword)); fonttables[font_number][0].cint = sizeword.cint; undumpthings(fonttables[font_number][1], sizeword.cint); } +#if 0 /* unused */ memoryword **fontsorttables; static int fontsort_entries = 0; @@ -385,14 +384,13 @@ allocatefontsorttable (int fontsort_number, int fontsort_size) { int i; if (fontsort_entries==0) { - fontsorttables = (memoryword **) xmalloc(256*sizeof(memoryword**)); + fontsorttables = xmalloc(256*sizeof(memoryword*)); fontsort_entries=256; } else if ((fontsort_number==256)&&(fontsort_entries==256)) { - fontsorttables = xrealloc(fontsorttables, 65536); + fontsorttables = xrealloc(fontsorttables, 65536*sizeof(memoryword*)); fontsort_entries=65536; } - fontsorttables[fontsort_number] = - (memoryword *) xmalloc((fontsort_size+1)*sizeof(memoryword)); + fontsorttables[fontsort_number] = xmalloc((fontsort_size+1)*sizeof(memoryword)); fontsorttables[fontsort_number][0].cint = fontsort_size; fontsorttables[fontsort_number][0].cint1 = 0; for (i=1; i<=fontsort_size; i++) { @@ -414,19 +412,19 @@ undumpfontsorttable(int fontsort_number) { memoryword sizeword; if (fontsort_entries==0) { - fontsorttables = (memoryword **) xmalloc(256*sizeof(memoryword**)); + fontsorttables = xmalloc(256*sizeof(memoryword*)); fontsort_entries=256; } else if ((fontsort_number==256)&&(fontsort_entries==256)) { - fontsorttables = xrealloc(fontsorttables, 65536); + fontsorttables = xrealloc(fontsorttables, 65536*sizeof(memoryword*)); fontsort_entries=65536; } undumpthings(sizeword,1); - fontsorttables[fontsort_number] = - (memoryword *) xmalloc((sizeword.cint+1)*sizeof(memoryword)); + fontsorttables[fontsort_number] = xmalloc((sizeword.cint+1)*sizeof(memoryword)); fontsorttables[fontsort_number][0].cint = sizeword.cint; undumpthings(fontsorttables[fontsort_number][1], sizeword.cint); } +#endif int **ocptables; static int ocp_entries = 0; @@ -436,14 +434,13 @@ allocateocptable (int ocp_number, int ocp_size) { int i; if (ocp_entries==0) { - ocptables = (int **) xmalloc(256*sizeof(int**)); + ocptables = xmalloc(256*sizeof(int*)); ocp_entries=256; } else if ((ocp_number==256)&&(ocp_entries==256)) { - ocptables = xrealloc(ocptables, 65536); + ocptables = xrealloc(ocptables, 65536*sizeof(int*)); ocp_entries=65536; } - ocptables[ocp_number] = - (int *) xmalloc((1+ocp_size)*sizeof(int)); + ocptables[ocp_number] = xmalloc((1+ocp_size)*sizeof(int)); ocptables[ocp_number][0] = ocp_size; for (i=1; i<=ocp_size; i++) { ocptables[ocp_number][i] = 0; @@ -461,15 +458,14 @@ undumpocptable (int ocp_number) { int sizeword; if (ocp_entries==0) { - ocptables = (int **) xmalloc(256*sizeof(int**)); + ocptables = xmalloc(256*sizeof(int*)); ocp_entries=256; } else if ((ocp_number==256)&&(ocp_entries==256)) { - ocptables = xrealloc(ocptables, 65536); + ocptables = xrealloc(ocptables, 65536*sizeof(int*)); ocp_entries=65536; } undumpthings(sizeword,1); - ocptables[ocp_number] = - (int *) xmalloc((1+sizeword)*sizeof(int)); + ocptables[ocp_number] = xmalloc((1+sizeword)*sizeof(int)); ocptables[ocp_number][0] = sizeword; undumpthings(ocptables[ocp_number][1], sizeword); } diff --git a/Build/source/texk/web2c/alephdir/omocp.ch b/Build/source/texk/web2c/alephdir/omocp.ch index 3150d5943a9..4b6d1cb2a46 100644 --- a/Build/source/texk/web2c/alephdir/omocp.ch +++ b/Build/source/texk/web2c/alephdir/omocp.ch @@ -316,7 +316,6 @@ begin g:=null_ocp;@/ done|; otherwise |incr(ocp_ptr)| and |goto done|@>; bad_ocp: @; done: if file_opened then b_close(ocp_file); -ocp_name(f):=nom; ocp_area(f):=aire; read_ocp_info:=g; end; @@ -336,16 +335,28 @@ help2("I wasn't able to read the data for this ocp,")@/ error @ @= +file_opened:=false; +if (ocp_ptr=ocp_biggest) then + @; if external_ocp then @ else begin @; @; end; +ocp_name(f):=nom; ocp_area(f):=aire + +@ @= +begin start_ocp_error_message; +print(" not loaded: Not enough room left"); +@.Translation process x=xx not loaded...@> +help2("I cant handle more than 65535 translation processes,")@/ +("so I will ignore the ocp specification."); +error; goto done; +end @ @= begin -file_opened:=false; pack_file_name(nom,aire,ext); b_test_in; if name_length=0 then ocp_abort("opening file"); @@ -367,7 +378,6 @@ goto done; end @ @= -file_opened:=false; pack_file_name(nom,aire,".ocp"); if not b_open_in(ocp_file) then ocp_abort("opening file"); file_opened:=true -- cgit v1.2.3