In some cases, strlower_m() (strupper()) is called after a function that sets errno to non-zero if it failed. This is bad things because strlower_m() and strupper_m() override errno if a target string has multibyte chars. For example, in source/smbd/open.c:open_file(): 1: /* Actually do the open */ 2: fsp->fd = fd_open(conn, fname, local_flags, mode); 3: if (fsp->fd == -1) { 4: DEBUG(3,("Error opening file %s (%s) (local_flags=%d) (flags=%d)\n", 5: fname,strerror(errno),local_flags,flags)); 6: check_for_pipe(fname); 7: return False; 8: } 2: If fd_open() is failed, it sets errno to non-zero to indicate what went wrong and returns -1. 3: The following expressions (line 4, 5, 6 and 7) are processed because fsp->fd is equal to -1. 6: check_for_pipe(fname) calls: StrnCpy(s,fname,sizeof(s)-1); and: strlower_m(s); If fname have multibyte chars, strlower_m(s) sets errno to 0 (and sets to something else if unix_strlower() is failed). 7: Return to caller. Caller cannot identify the cause of error.
Created attachment 574 [details] Proposed patch to save errno
Created attachment 575 [details] Proposed patch to save errno
Comment, please...
Jeremy, here's another one for you. Thanks.
Correct fix ! Applied. Thanks. Jeremy.
originally against 3.0.5rc1 (which was 34.0.6rc1 due to the security release).
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.