Summary: | gsicc_manage opens file with spurious second 'b' for binary mode | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | norbert.janssen |
Component: | Graphics Library | Assignee: | Chris Liddell (chrisl) <chris.liddell> |
Status: | NOTIFIED FIXED | ||
Severity: | normal | CC: | chris.liddell |
Priority: | P2 | ||
Version: | master | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
Customer: | 661 | Word Size: | --- |
Description
norbert.janssen
2015-07-20 01:43:31 UTC
I saw that there are lots of places where an "rb" is passed as access_mode. Perhaps it is better to check for a 'b' in the mode before adding the gp_fmode_binary_suffix. This would be in zfile.c::ztempfile() sfxcommon.c::file_prepare_stream() ztempfile() is also protected by parse_file_access_string() which will only pass a 'a', 'r', 'w' or "a+", "r+", "w+". So this only leaves sfxcommon.c::file_prepare_stream() /* Open the file, always in binary mode. */ strcpy(fmode, file_access); if (strrchr(file_access, 'b') == null) { strcat(fmode, gp_fmode_binary_suffix); } My preference would be to fix the users of the API in question - since the API always opens files in binary mode (where applicable), it seems best, to me, to ensure that no callers add the 'b', and put protection in place to ensure we catch any new code which does so - add a warning and an assert to catch any callers adding the 'b'. |