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

Bug#316501: trailing characters when displaying long multiline descriptions



You wrote:
> When cdebconf displays a template with multiline descriptions, the last
> n(n== the number of of newlines in the original extended_description)
> characters of the description will be shown after it.
> The origin of the problem is the remove_newline function in template.c, which
> doeasn't apply a \0 after the truncated string.

We don't see this problem in day-to-day use of cdebconf. Do you have a
way to reproduce the problem?

The code is:

        in = out = text;
        for (; *in != 0; in++)
        {
                *out = *in;
                if (*in == '\n')
                {
                        if (*(in+1) == '.' && *(in+2) == '\n')
                        {
                                out++;
                                *out = *in;
                                in+=2;
                                asis=0;
                        }
                        else if (*(in+1) == ' ')
                                asis=1;
                        else if (asis)
                                asis=0;
                        else
                        {
                                if (*(in+1) != 0)
                                        *out = ' ';
                                else
                                        *out = 0;
                        }
                }
                out++;
        }

I assume the string ends in a newline since it's an extended description
string. (Haven't checked that.) If it does then the last character processed
will be that newline, and it will normally end up setting *out = 0 which \0
terminates the string correctly.

Hmm, this might fail with a string like this: "xxx\n \n"
In that case, asis will be set when it encounters the "\n " and then the final
"\n" will be copied in but nothing else done since asis is set.

One other failure mode would be a string like "xxx\n.\n", which would
similarly avoid the \0 termination.

Are these the cases you had in mind or am I missing a worse failure mode?

-- 
see shy jo

Attachment: signature.asc
Description: Digital signature


Reply to: