Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 149964 Details for
Bug 203725
wxGetUserName() buggy, causes crashes
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch against wxGTK 2.8.1 to fix the issue
wxusername.patch (text/plain), 5.38 KB, created by
İsmail Dönmez
on 2007-03-13 18:04:42 UTC
(
hide
)
Description:
Patch against wxGTK 2.8.1 to fix the issue
Filename:
MIME Type:
Creator:
İsmail Dönmez
Created:
2007-03-13 18:04:42 UTC
Size:
5.38 KB
patch
obsolete
>--- wxwidgets2.8-2.8.1.1.orig/include/wx/strconv.h >+++ wxwidgets2.8-2.8.1.1/include/wx/strconv.h >@@ -523,10 +523,27 @@ > #if wxUSE_UNICODE > #define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s) > #define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s) >+ >+#if wxABI_VERSION >= 20802 >+ // these functions should be used when the conversions really, really have >+ // to succeed (usually because we pass their results to a standard C >+ // function which would crash if we passed NULL to it), so these functions >+ // always return a valid pointer if their argument is non-NULL >+ >+ // this function safety is achieved by trying wxConvLibc first, wxConvUTF8 >+ // next if it fails and, finally, wxConvISO8859_1 which always succeeds >+ extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s); >+ >+ // this function uses wxConvLibc and wxConvUTF8(MAP_INVALID_UTF8_TO_OCTAL) >+ // if it fails >+ extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws); >+#endif // wxABI 2.8.2+ > #else // ANSI > // no conversions to do > #define wxConvertWX2MB(s) (s) > #define wxConvertMB2WX(s) (s) >+ #define wxSafeConvertMB2WX(s) (s) >+ #define wxSafeConvertWX2MB(s) (s) > #endif // Unicode/ANSI > > #endif // _WX_STRCONV_H_ >only in patch2: >unchanged: >--- wxwidgets2.8-2.8.1.1.orig/src/unix/utilsunx.cpp >+++ wxwidgets2.8-2.8.1.1/src/unix/utilsunx.cpp >@@ -473,7 +473,7 @@ > > while (argv[mb_argc]) > { >- wxWX2MBbuf mb_arg = wxConvertWX2MB(argv[mb_argc]); >+ wxWX2MBbuf mb_arg = wxSafeConvertWX2MB(argv[mb_argc]); > mb_argv[mb_argc] = strdup(mb_arg); > mb_argc++; > } >@@ -722,7 +722,7 @@ > } > if ((ptr = wxGetenv(wxT("USER"))) != NULL || (ptr = wxGetenv(wxT("LOGNAME"))) != NULL) > { >- who = getpwnam(wxConvertWX2MB(ptr)); >+ who = getpwnam(wxSafeConvertWX2MB(ptr)); > } > > // We now make sure the the user exists! >@@ -736,7 +736,7 @@ > who = getpwnam (user.mb_str()); > } > >- return wxConvertMB2WX(who ? who->pw_dir : 0); >+ return wxSafeConvertMB2WX(who ? who->pw_dir : 0); > } > > // ---------------------------------------------------------------------------- >@@ -787,7 +787,7 @@ > bool ok = uname(&uts) != -1; > if ( ok ) > { >- wxStrncpy(buf, wxConvertMB2WX(uts.nodename), sz - 1); >+ wxStrncpy(buf, wxSafeConvertMB2WX(uts.nodename), sz - 1); > buf[sz] = wxT('\0'); > } > #elif defined(HAVE_GETHOSTNAME) >@@ -795,7 +795,7 @@ > bool ok = gethostname(cbuf, sz) != -1; > if ( ok ) > { >- wxStrncpy(buf, wxConvertMB2WX(cbuf), sz - 1); >+ wxStrncpy(buf, wxSafeConvertMB2WX(cbuf), sz - 1); > buf[sz] = wxT('\0'); > } > #else // no uname, no gethostname >@@ -839,7 +839,7 @@ > { > if ( !wxStrchr(buf, wxT('.')) ) > { >- struct hostent *host = gethostbyname(wxConvertWX2MB(buf)); >+ struct hostent *host = gethostbyname(wxSafeConvertWX2MB(buf)); > if ( !host ) > { > wxLogSysError(_("Cannot get the official hostname")); >@@ -849,7 +849,7 @@ > else > { > // the canonical name >- wxStrncpy(buf, wxConvertMB2WX(host->h_name), sz); >+ wxStrncpy(buf, wxSafeConvertMB2WX(host->h_name), sz); > } > } > //else: it's already a FQDN (BSD behaves this way) >@@ -865,7 +865,7 @@ > *buf = wxT('\0'); > if ((who = getpwuid(getuid ())) != NULL) > { >- wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1); >+ wxStrncpy (buf, wxSafeConvertMB2WX(who->pw_name), sz - 1); > return true; > } > >@@ -874,24 +874,23 @@ > > bool wxGetUserName(wxChar *buf, int sz) > { >+#ifdef HAVE_PW_GECOS > struct passwd *who; > > *buf = wxT('\0'); > if ((who = getpwuid (getuid ())) != NULL) > { >- // pw_gecos field in struct passwd is not standard >-#ifdef HAVE_PW_GECOS > char *comma = strchr(who->pw_gecos, ','); > if (comma) > *comma = '\0'; // cut off non-name comment fields >- wxStrncpy (buf, wxConvertMB2WX(who->pw_gecos), sz - 1); >-#else // !HAVE_PW_GECOS >- wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1); >-#endif // HAVE_PW_GECOS/!HAVE_PW_GECOS >+ wxStrncpy (buf, wxSafeConvertMB2WX(who->pw_gecos), sz - 1); > return true; > } > > return false; >+#else // !HAVE_PW_GECOS >+ return wxGetUserId(buf, sz); >+#endif // HAVE_PW_GECOS/!HAVE_PW_GECOS > } > > bool wxIsPlatform64Bit() >only in patch2: >unchanged: >--- wxwidgets2.8-2.8.1.1.orig/src/common/strconv.cpp >+++ wxwidgets2.8-2.8.1.1/src/common/strconv.cpp >@@ -3650,9 +3650,39 @@ > #else > wxConvUTF8Obj; > #endif >-#else >+#else // !__WXOSX__ > wxConvLibcObj; >-#endif >+#endif // __WXOSX__/!__WXOSX__ >+ >+#if wxUSE_UNICODE >+ >+wxWCharBuffer wxSafeConvertMB2WX(const char *s) >+{ >+ if ( !s ) >+ return wxWCharBuffer(); >+ >+ wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s)); >+ if ( !wbuf ) >+ wbuf = wxConvUTF8.cMB2WX(s); >+ if ( !wbuf ) >+ wbuf = wxConvISO8859_1.cMB2WX(s); >+ >+ return wbuf; >+} >+ >+wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws) >+{ >+ if ( !ws ) >+ return wxCharBuffer(); >+ >+ wxCharBuffer buf(wxConvLibc.cWX2MB(ws)); >+ if ( !buf ) >+ buf = wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL).cWX2MB(ws); >+ >+ return buf; >+} >+ >+#endif // wxUSE_UNICODE > > #else // !wxUSE_WCHAR_T >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 203725
:
134712
| 149964