Bug 1546 - strupper_m and strlower_m set errno to 0 if a string has multibyte chars
Summary: strupper_m and strlower_m set errno to 0 if a string has multibyte chars
Status: CLOSED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.5
Hardware: All Linux
: P3 normal
Target Milestone: none
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-22 03:13 UTC by SATOH Fumiyasu
Modified: 2005-08-24 10:18 UTC (History)
1 user (show)

See Also:


Attachments
Proposed patch to save errno (2.72 KB, patch)
2004-07-22 03:15 UTC, SATOH Fumiyasu
no flags Details
Proposed patch to save errno (1.40 KB, patch)
2004-07-22 03:16 UTC, SATOH Fumiyasu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description SATOH Fumiyasu 2004-07-22 03:13:14 UTC
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.
Comment 1 SATOH Fumiyasu 2004-07-22 03:15:48 UTC
Created attachment 574 [details]
Proposed patch to save errno
Comment 2 SATOH Fumiyasu 2004-07-22 03:16:13 UTC
Created attachment 575 [details]
Proposed patch to save errno
Comment 3 SATOH Fumiyasu 2004-09-01 08:24:02 UTC
Comment, please...
Comment 4 Gerald (Jerry) Carter (dead mail address) 2004-09-01 08:51:59 UTC
Jeremy, here's another one for you.  Thanks.
Comment 5 Jeremy Allison 2004-09-01 10:39:04 UTC
Correct fix ! Applied. Thanks.

Jeremy.
Comment 6 Gerald (Jerry) Carter (dead mail address) 2005-02-07 09:56:12 UTC
originally against 3.0.5rc1 (which was 34.0.6rc1 due to the security release).
Comment 7 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:18:11 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.