On Mon, Mar 23, 2026 at 10:51:49AM +0200, Andy Shevchenko wrote:
> On Fri, Mar 20, 2026 at 05:48:44PM -0700, Kees Cook wrote:

...

> > -                   char tmp[42];
> >  
> >                     __be32 *dt = (__be32 *)dostype;
> >                     *dt = pb->pb_Environment[16];
> >                     if (dostype[3] < ' ')
> > -                           snprintf(tmp, sizeof(tmp), " (%c%c%c^%c)",
> > -                                   dostype[0], dostype[1],
> > -                                   dostype[2], dostype[3] + '@' );
> > +                           seq_buf_printf(&state->pp_buf,
> > +                                          " (%c%c%c^%c)",
> > +                                          dostype[0], dostype[1],
> > +                                          dostype[2],
> > +                                          dostype[3] + '@');
> >                     else
> > -                           snprintf(tmp, sizeof(tmp), " (%c%c%c%c)",
> > -                                   dostype[0], dostype[1],
> > -                                   dostype[2], dostype[3]);
> > -                   strlcat(state->pp_buf, tmp, PAGE_SIZE);
> > -                   snprintf(tmp, sizeof(tmp), "(res %d spb %d)",
> > -                           be32_to_cpu(pb->pb_Environment[6]),
> > -                           be32_to_cpu(pb->pb_Environment[4]));
> > -                   strlcat(state->pp_buf, tmp, PAGE_SIZE);
> > +                           seq_buf_printf(&state->pp_buf,
> > +                                          " (%c%c%c%c)",
> > +                                          dostype[0], dostype[1],
> > +                                          dostype[2], dostype[3]);
> 
> Wouldn't
>                               seq_buf_printf(&state->pp_buf, " (%.4s)", 
> dostype);
> 
> work?
> 
> But probably okay as in the previous branch it needs more work to follow,
> something like
> 
>                       char dostype[8];
>                       ...
>                       if (dostype[3] < ' ') {
>                               /* Escape control character */
>                               dostype[4] = dostype[3] + '@';
>                               dostype[3] = '^';
>                               seq_buf_printf(&state->pp_buf, " (%.5s)", 
> dostype);
>                       } else {
>                               seq_buf_printf(&state->pp_buf, " (%.4s)", 
> dostype);
>                       }

Or maybe even replace the whole conditional with

                        seq_buf_printf(&state->pp_buf, " (%4pE)", dostype);

What do you think?

> Taking how invasive is this, it might be better to done separately.
> 
> > +                   seq_buf_printf(&state->pp_buf, "(res %d spb %d)",
> > +                                  be32_to_cpu(pb->pb_Environment[6]),
> > +                                  be32_to_cpu(pb->pb_Environment[4]));

-- 
With Best Regards,
Andy Shevchenko



Reply via email to