[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pkg-shadow-devel
Subject:    [Pkg-shadow-devel] =?utf-8?q?=5Bpkg-shadow-Bugs=5D=5B313942=5D_ne?= =?utf-8?q?w=5Fline_gets_truncate
From:       <pkg-shadow-bugs () alioth ! debian ! org>
Date:       2013-07-29 9:07:16
Message-ID: E1V3jQC-0008Qc-9X () vasks ! debian ! org
[Download RAW message or body]

pkg-shadow-Bugs item #313942 was changed at 2013-07-29 11:07 by Christian Perrier
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=411478&aid=313942&group_id=30580

> Status: Pending
Priority: 3
Submitted By: Brad Hubbard (badone-guest)
Assigned to: Nobody (None)
Summary: new_line gets truncated in merge_group_entries 
Category: None
Group: None
Resolution: None


Initial Comment:
In the following code allowance is made for the terminating NULL in new_line_len but \
not the newline char that is added when the two lines are concatenated. The result is \
new_line ends up one character short.

    314         /* Concatenate the 2 lines */
    315         new_line_len = strlen (gr1->line) + strlen (gr2->line) +1;
    316         new_line = (char *)malloc ((new_line_len + 1) * sizeof(char*));
    317         if (NULL == new_line) {
    318                 errno = ENOMEM;
    319                 return NULL;
    320         }
    321         snprintf(new_line, new_line_len, "%s\n%s", gr1->line, gr2->line);
    322         new_line[new_line_len] = '\0';

Patch attached.

----------------------------------------------------------------------

Comment By: Christian Perrier (bubulle)
Date: 2013-07-29 10:07

Message:
I committed the original patch. Improved patch would be appreciated

----------------------------------------------------------------------

Comment By: Tomáš Mráz (tmraz-guest)
Date: 2013-01-29 14:05

Message:
The patch is not quite correct. The malloc is sizeof(char*) times more than needed. \
And the fix should be by changing the snprintf() to use new_line_len+1 which is the \
number of bytes we would allocate (if there wasn't the overallocation).


----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=411478&aid=313942&group_id=30580


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic