Open bentsi opened 6 years ago
what exactly is the problem you're trying to solve ?
The problem here is that when setting TMPDIR env variable to path that exceeds 128 characters iogen crashes with coredump.
I run iogen in path that exceeds 128 characters, and it crashes with coredump. The program should not crash with coredump in such case. The solution is or to check path length and exit with error or increase MAX_FNAME_LENGTH to some bigger value
Actually both should be done, I will push a commit that increases the MAX_FNAME_LENGHT, that one is easy enough.
Looking at the code the offending part is likely the function parse_cmdline() and the code that does getcwd() into array of size of MAX_FNAME_LENGTH then strcat() the filename at the end.
However the whole code looks like it will need some love, some parts are duplicated, some should be removed completely, such as the parts that were written to support non-POSIX conforming system such as CRAY or SGI...
And it looks like the tests start to fail if I increase the MAX_FNAME_LENGTH and recompile, so the value is possibly hardcoded somewhere in the code :-(.
Okay it looks like we need to fit the structures to be less than PIPE_BUF which is the largest atomic write for a pipe. The minimal value for PIPE_BUF is 512, which is probably the reason why the paths are so short. We can bump it to something as 400 bytes safely and even to 4000 for Linux since PIPE_BUF is 4k there.
ltp/testcases/kernel/fs/doio/doio.h MAX_FNAME_LENGTH should have value greater than 128 or maximum allowed by the OS