Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stgbuf, stgpipe, stgmark: (un)signed char #9

Closed
jte opened this issue Jan 12, 2014 · 0 comments
Closed

stgbuf, stgpipe, stgmark: (un)signed char #9

jte opened this issue Jan 12, 2014 · 0 comments

Comments

@jte
Copy link

jte commented Jan 12, 2014

The problem that may concern some compilers is that "sEXPRSTART" is defined as 0x80 and buffers "stgbuf", "stgpipe", function "stgmark" and other releated functions which deal with them are defined as "char" which if the compiler defines it to be "signed" means that the maximum is SCHAR_MAX which is 2^7-1 or 127 or 0x7F clearly causing overflow, if the compiler defines the "char" as "unsigned" then there won't be any problems because the maximum is UCHAR_MAX which is 2^8-1 or 255 or 0xFF. Note that "sEXPRSTART" directly relates to the "sMAXARGS" defined as 127(0x7F) which is maximum amount of arguments. Probably the best solution is to define everything that concerns those buffers as "unsigned char" and cast it to appropriate "char" where needed(e.g. strlen).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants