bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem using install-info with tar.info


From: Alan Wehmann
Subject: Re: problem using install-info with tar.info
Date: Sat, 7 Nov 2015 08:54:20 -0600

Here is the Diff output:

diff -u install-info.c install-info-fixed.c
--- install-info.c      2015-02-27 12:57:27.000000000 -0600
+++ install-info-fixed.c        2015-11-07 08:48:36.000000000 -0600
@@ -1445,6 +1445,8 @@
       if (c == '\n')
         {
           line_out[offset_out++] = c;
+          line_out = (char *) realloc ((void *)line_out, allocated_out+1);
+         line_out[offset_out+1] = '\0';
           strncat (*outstr, line_out, offset_out);
           column = offset_out = 0;
           continue;

Alan Wehmann
address@hidden


> On Nov 7, 2015, at 6:41 AM, Gavin Smith <address@hidden> wrote:
> 
> On 4 November 2015 at 18:38, Alan Wehmann <address@hidden> wrote:
>> In "install-info_orig_seq.c" the line:
>> 
>> 1447              strncat (*outstr, line_out, offset_out);
>> 
>> is where the error occurred.
>> 
>> After some study I decided to try making sure that "line_out" is terminated 
>> by a '\0' character, so I have the code in "install-info_altered_seq.c":
>> 
>> 1465              line_out = (char *) realloc ((void *)line_out, 
>> allocated_out+1);
>> 1466              line_out[offset_out+1] = '\0';
>> 
>> that adds a '\0' character to "line_out" and allocates space for it.
>> This seemed to make the problem with “strncat” go away.
> 
> Assuming offset_out isn't too big (it wasn't as far as I could tell),
> my best guess is that strncat is reading too far in the source array,
> and extending its allocation prevents an error being signalled.
> 
> Diffs are preferred for showing the changes you made to code, for
> example "cp install-info.c install-info-fixed.c", then edit
> install-info-fixed.c, finally post the output of "diff -u
> install-info.c install-info-fixed.c".




reply via email to

[Prev in Thread] Current Thread [Next in Thread]