Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

devdraw should probably return Eshortread if you pass 144 characters #1163

Open
@floren

Description

@floren

Right now, in the drawread function, the Qctl case checks if the buffer is LESS than 144 characters:

                if(n < 12*12)
                        error(Eshortread);

But then it does this snprint:

                n = snprint(a, n,
                        "%11d %11d %11s %11d %11d %11d %11d %11d %11d %11d %11d %11d ",
                        cl->clientid, cl->infoid, chantostr(buf, i->chan),
                        (i->flags&Frepl)==Frepl,
                        i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
                        i->clipr.min.x, i->clipr.min.y, i->clipr.max.x,
                        i->clipr.max.y);

That string is 144 characters long. snprint always leaves room for a NULL character at the end, so if you pass in a 144 character array (n = 144), it ends up chopping off the final space character. The return value is then 143.

This leads to a corner case where drawread isn't able to write the full string into memory, but it also doesn't return an error.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions