Skip to content
This repository has been 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 opened this issue Sep 2, 2021 · 0 comments
Open

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

floren opened this issue Sep 2, 2021 · 0 comments
Assignees

Comments

@floren
Copy link
Contributor

floren commented Sep 2, 2021

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.

@floren floren self-assigned this Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant