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

segfault #8

Closed
BrainSlayer opened this issue Feb 22, 2019 · 8 comments
Closed

segfault #8

BrainSlayer opened this issue Feb 22, 2019 · 8 comments

Comments

@BrainSlayer
Copy link

a 100% segfault on big endian is the missuse of a long long number for pointers in the config parser for the rawoption option number. this will crash on and mips big endian system. use "long" or use a string or even use a numeric value. but never use 64 bit integers as casted pointer here.

@marjohn56
Copy link
Member

Can you point out where this is in the code, I've looked and failed to see- not unusual!

@BrainSlayer
Copy link
Author

its easy. the yacc/bison generators uses long long integers for integers but its a string pointer in reality an this integer is casted to a pointer later again. this fails on big endian 32 bit systems of course . it turns to zero. i fixed that already in the dd-wrt repository

@marjohn56
Copy link
Member

Probably best if you issue a PR for it. You can discuss with Franco. :)

@marjohn56
Copy link
Member

Calling him in shout out to @fichtner

@fichtner
Copy link
Member

fichtner commented Mar 5, 2019

we do not have big endian builds nor lack of politeness over here, so we are fine

@BrainSlayer
Copy link
Author

my solution is a quick and dirty workaround. the problem isnt solved. pointer should not be casted to long long integers and back to pointers in any way. long long is 64 bit and pointers can be 32 bit or 64 bit depending on the system and big and little endian fucks it up at the end if you try to cast them. my solution is that i fixed all integers to long instead of long long. so the datatype fits to the system at the end

@BrainSlayer
Copy link
Author

BrainSlayer commented Mar 5, 2019

@fichtner : thats the worst answer i've ever seen. in embedded systems where dhcp6c is used widely big endian systems are common. mips for instance. or xscale. i know you made it with intension to be used for freebsd. but since patches like custom options (-x) are getting important for routers as well to support strange isp's i decided to use this version here for integration into dd-wrt. or at least some patches of it. so i found out that the code is not correct at all and it no excuse to say that you never have seen a problem with it since your target isnt big endian. other targets might be. even with freebsd. and its simple to fix. the current way of handling pointers for the config parser is per definition incorrect. long long cannot be casted to pointers. since the length of a pointer is undefined depending on the architecture, but the size of long long is fixed to 64 bit

@opnsense opnsense locked as off-topic and limited conversation to collaborators Mar 5, 2019
@fichtner fichtner closed this as completed Mar 5, 2019
@fichtner
Copy link
Member

fichtner commented Mar 5, 2019

@BrainSlayer you will be blocked if you keep indicating how bad we are and how much all of this sucks, and if you want to prove how clever you are just open a PR so we can talk review :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants