[PATCH 0/1] MR352: cmd: Don't loop infinitely on NUL.
eric pouech (@epo)
wine at gitlab.winehq.org
Thu Jun 30 10:49:43 CDT 2022
I'm not concerned about droping all characters after the NULL (1)
I'm concerned by what's before the NUL character! and basically what should be an marker for end of file
if instead of writing "a b c\n\0f .." into your test file, you just write "a b c\0" (removing the CR at the end of "a b c", I believe that "a b c" should be returned by WCMD_fgets and subsequent WCMD_fgets should return NULL to mark EOF.
(so from a cursory look in pseudo code
if (*p == '\0' && p > bufA) break; /* reposition at '\0' to reread the NULL in next call) */
if (*p == '\0' && p == bufA) return NULL;
(1): if you have time, it would be interesting to see what happens if instead of \0, ^Z (0x1A) is used (it's the end of text file marker in the old DOS days). I wouldn't be surprised if it stops also reading the file.
(and maybe at some point we'd better use read/write from msvcrt which should handle all this DOS stuff directly, but that's likely a too large change for what you're trying to solve)
since WCMD_fgets is used by most of the input methods, I want to be sure that this doens't break other things
More information about the wine-devel