File: | sal/osl/unx/module.cxx |
Location: | line 189, column 9 |
Description: | Array access (from variable 'relativePath') results in a null pointer dereference |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||||
2 | /************************************************************************* | |||||
3 | * | |||||
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||||
5 | * | |||||
6 | * Copyright 2000, 2010 Oracle and/or its affiliates. | |||||
7 | * | |||||
8 | * OpenOffice.org - a multi-platform office productivity suite | |||||
9 | * | |||||
10 | * This file is part of OpenOffice.org. | |||||
11 | * | |||||
12 | * OpenOffice.org is free software: you can redistribute it and/or modify | |||||
13 | * it under the terms of the GNU Lesser General Public License version 3 | |||||
14 | * only, as published by the Free Software Foundation. | |||||
15 | * | |||||
16 | * OpenOffice.org is distributed in the hope that it will be useful, | |||||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
19 | * GNU Lesser General Public License version 3 for more details | |||||
20 | * (a copy is included in the LICENSE file that accompanied this code). | |||||
21 | * | |||||
22 | * You should have received a copy of the GNU Lesser General Public License | |||||
23 | * version 3 along with OpenOffice.org. If not, see | |||||
24 | * <http://www.openoffice.org/license.html> | |||||
25 | * for a copy of the LGPLv3 License. | |||||
26 | * | |||||
27 | ************************************************************************/ | |||||
28 | ||||||
29 | #include "sal/config.h" | |||||
30 | ||||||
31 | #include <sal/log.hxx> | |||||
32 | #include <sal/types.h> | |||||
33 | #include <osl/module.h> | |||||
34 | #include <osl/thread.h> | |||||
35 | #include <osl/process.h> | |||||
36 | #include <osl/file.h> | |||||
37 | ||||||
38 | #include "system.h" | |||||
39 | ||||||
40 | #ifdef AIX | |||||
41 | #include <sys/ldr.h> | |||||
42 | #endif | |||||
43 | ||||||
44 | #ifdef ANDROID | |||||
45 | #include <osl/detail/android-bootstrap.h> | |||||
46 | #endif | |||||
47 | ||||||
48 | /* implemented in file.c */ | |||||
49 | extern "C" int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); | |||||
50 | ||||||
51 | static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) { | |||||
52 | sal_Bool result = sal_False((sal_Bool)0); | |||||
53 | // We do want to have this functionality also in the | |||||
54 | // DISABLE_DYNLOADING case, I think? | |||||
55 | #if defined(AIX) | |||||
56 | int size = 4 * 1024; | |||||
57 | char *buf, *filename=NULL__null; | |||||
58 | struct ld_info *lp; | |||||
59 | ||||||
60 | if ((buf = malloc(size)) == NULL__null) | |||||
61 | return result; | |||||
62 | ||||||
63 | while(loadquery(L_GETINFO, buf, size) == -1 && errno(*__errno_location ()) == ENOMEM12) | |||||
64 | { | |||||
65 | size += 4 * 1024; | |||||
66 | if ((buf = malloc(size)) == NULL__null) | |||||
67 | break; | |||||
68 | } | |||||
69 | ||||||
70 | lp = (struct ld_info*) buf; | |||||
71 | while (lp) | |||||
72 | { | |||||
73 | unsigned long start = (unsigned long)lp->ldinfo_dataorg; | |||||
74 | unsigned long end = start + lp->ldinfo_datasize; | |||||
75 | if (start <= (unsigned long)address && end > (unsigned long)address) | |||||
76 | { | |||||
77 | filename = lp->ldinfo_filename; | |||||
78 | break; | |||||
79 | } | |||||
80 | if (!lp->ldinfo_next) | |||||
81 | break; | |||||
82 | lp = (struct ld_info*) ((char *) lp + lp->ldinfo_next); | |||||
83 | } | |||||
84 | ||||||
85 | if (filename) | |||||
86 | { | |||||
87 | rtl_string_newFromStr(path, filename); | |||||
88 | result = sal_True((sal_Bool)1); | |||||
89 | } | |||||
90 | else | |||||
91 | { | |||||
92 | result = sal_False((sal_Bool)0); | |||||
93 | } | |||||
94 | ||||||
95 | free(buf); | |||||
96 | #else | |||||
97 | Dl_info dl_info; | |||||
98 | ||||||
99 | #ifdef ANDROID | |||||
100 | result = lo_dladdr(address, &dl_info); | |||||
101 | #else | |||||
102 | result = dladdr(address, &dl_info); | |||||
103 | #endif | |||||
104 | ||||||
105 | if (result != 0) | |||||
106 | { | |||||
107 | rtl_string_newFromStr(path, dl_info.dli_fname); | |||||
108 | #ifdef ANDROID | |||||
109 | free((void *) dl_info.dli_fname); | |||||
110 | #endif | |||||
111 | result = sal_True((sal_Bool)1); | |||||
112 | } | |||||
113 | else | |||||
114 | { | |||||
115 | result = sal_False((sal_Bool)0); | |||||
116 | } | |||||
117 | #endif | |||||
118 | return result; | |||||
119 | } | |||||
120 | ||||||
121 | /*****************************************************************************/ | |||||
122 | /* osl_loadModule */ | |||||
123 | /*****************************************************************************/ | |||||
124 | ||||||
125 | oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMode) | |||||
126 | { | |||||
127 | oslModule pModule=0; | |||||
128 | rtl_uString* ustrTmp = NULL__null; | |||||
129 | ||||||
130 | SAL_WARN_IF(ustrModuleName == 0, "sal.osl", "string is not valid")do { if (true && (ustrModuleName == 0)) { if (sizeof :: sal::detail::getResult( ::sal::detail::StreamStart() << "string is not valid") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "130" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "string is not valid")); } else { ::std ::ostringstream sal_detail_stream; sal_detail_stream << "string is not valid"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "130" ": "), sal_detail_stream); } } } while (false); | |||||
131 | ||||||
132 | /* ensure ustrTmp hold valid string */ | |||||
133 | if (osl_File_E_None != osl_getSystemPathFromFileURL(ustrModuleName, &ustrTmp)) | |||||
134 | rtl_uString_assign(&ustrTmp, ustrModuleName); | |||||
135 | ||||||
136 | if (ustrTmp) | |||||
137 | { | |||||
138 | char buffer[PATH_MAX4096]; | |||||
139 | ||||||
140 | if (UnicodeToText(buffer, PATH_MAX4096, ustrTmp->buffer, ustrTmp->length)) | |||||
141 | pModule = osl_loadModuleAscii(buffer, nRtldMode); | |||||
142 | rtl_uString_release(ustrTmp); | |||||
143 | } | |||||
144 | ||||||
145 | return pModule; | |||||
146 | } | |||||
147 | ||||||
148 | /*****************************************************************************/ | |||||
149 | /* osl_loadModuleAscii */ | |||||
150 | /*****************************************************************************/ | |||||
151 | ||||||
152 | oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nRtldMode) | |||||
153 | { | |||||
154 | SAL_WARN_IF(do { if (true && (((nRtldMode & 0x00001) != 0 && (nRtldMode & 0x00002) != 0))) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "only either LAZY or NOW" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "only either LAZY or NOW")); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "only either LAZY or NOW" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), sal_detail_stream); } } } while (false) | |||||
155 | ((nRtldMode & SAL_LOADMODULE_LAZY) != 0do { if (true && (((nRtldMode & 0x00001) != 0 && (nRtldMode & 0x00002) != 0))) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "only either LAZY or NOW" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "only either LAZY or NOW")); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "only either LAZY or NOW" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), sal_detail_stream); } } } while (false) | |||||
156 | && (nRtldMode & SAL_LOADMODULE_NOW) != 0),do { if (true && (((nRtldMode & 0x00001) != 0 && (nRtldMode & 0x00002) != 0))) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "only either LAZY or NOW" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "only either LAZY or NOW")); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "only either LAZY or NOW" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), sal_detail_stream); } } } while (false) | |||||
157 | "sal.osl", "only either LAZY or NOW")do { if (true && (((nRtldMode & 0x00001) != 0 && (nRtldMode & 0x00002) != 0))) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "only either LAZY or NOW" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "only either LAZY or NOW")); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "only either LAZY or NOW" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "157" ": "), sal_detail_stream); } } } while (false); | |||||
158 | if (pModuleName) | |||||
159 | { | |||||
160 | #ifndef DISABLE_DYNLOADING | |||||
161 | #ifdef ANDROID | |||||
162 | (void) nRtldMode; | |||||
163 | void *pLib = lo_dlopen(pModuleName); | |||||
164 | #else | |||||
165 | int rtld_mode = | |||||
166 | ((nRtldMode & SAL_LOADMODULE_NOW0x00002) ? RTLD_NOW0x00002 : RTLD_LAZY0x00001) | | |||||
167 | ((nRtldMode & SAL_LOADMODULE_GLOBAL0x00100) ? RTLD_GLOBAL0x00100 : RTLD_LOCAL0); | |||||
168 | void* pLib = dlopen(pModuleName, rtld_mode); | |||||
169 | ||||||
170 | SAL_INFO_IF(do { if (true && (pLib == 0)) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror(); ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), sal_detail_stream); } } } while (false) | |||||
171 | pLib == 0, "sal.osl",do { if (true && (pLib == 0)) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror(); ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), sal_detail_stream); } } } while (false) | |||||
172 | "dlopen(" << pModuleName << ", " << rtld_mode << "): "do { if (true && (pLib == 0)) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror(); ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), sal_detail_stream); } } } while (false) | |||||
173 | << dlerror())do { if (true && (pLib == 0)) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlopen(" << pModuleName << ", " << rtld_mode << "): " << dlerror(); ::sal::detail:: log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "173" ": "), sal_detail_stream); } } } while (false); | |||||
174 | #endif | |||||
175 | return ((oslModule)(pLib)); | |||||
176 | ||||||
177 | #else /* DISABLE_DYNLOADING */ | |||||
178 | (void) nRtldMode; | |||||
179 | fprintf(stderrstderr, "No DL Functions, osl_loadModuleAscii(%s) does nothing\n", pModuleName); | |||||
180 | #endif /* DISABLE_DYNLOADING */ | |||||
181 | } | |||||
182 | return NULL__null; | |||||
183 | } | |||||
184 | ||||||
185 | oslModule osl_loadModuleRelativeAscii( | |||||
186 | oslGenericFunction baseModule, char const * relativePath, sal_Int32 mode) | |||||
187 | { | |||||
188 | SAL_WARN_IF(relativePath == 0, "sal.osl", "illegal argument")do { if (true && (relativePath == 0)) { if (sizeof :: sal::detail::getResult( ::sal::detail::StreamStart() << "illegal argument") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "188" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "illegal argument")); } else { ::std:: ostringstream sal_detail_stream; sal_detail_stream << "illegal argument" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sal.osl" ), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "188" ": "), sal_detail_stream); } } } while (false); | |||||
| ||||||
189 | if (relativePath[0] == '/') { | |||||
| ||||||
190 | return osl_loadModuleAscii(relativePath, mode); | |||||
191 | } else { | |||||
192 | rtl_String * path = NULL__null; | |||||
193 | rtl_String * suffix = NULL__null; | |||||
194 | oslModule module; | |||||
195 | if (!getModulePathFromAddress( | |||||
196 | reinterpret_cast< void * >(baseModule), &path)) | |||||
197 | { | |||||
198 | return NULL__null; | |||||
199 | } | |||||
200 | rtl_string_newFromStr_WithLength( | |||||
201 | &path, path->buffer, | |||||
202 | (rtl_str_lastIndexOfChar_WithLength(path->buffer, path->length, '/') | |||||
203 | + 1)); | |||||
204 | /* cut off everything after the last slash; should the original path | |||||
205 | contain no slash, the resulting path is the empty string */ | |||||
206 | rtl_string_newFromStr(&suffix, relativePath); | |||||
207 | rtl_string_newConcat(&path, path, suffix); | |||||
208 | rtl_string_release(suffix); | |||||
209 | module = osl_loadModuleAscii(path->buffer, mode); | |||||
210 | rtl_string_release(path); | |||||
211 | return module; | |||||
212 | } | |||||
213 | } | |||||
214 | ||||||
215 | /*****************************************************************************/ | |||||
216 | /* osl_getModuleHandle */ | |||||
217 | /*****************************************************************************/ | |||||
218 | ||||||
219 | sal_Bool SAL_CALL | |||||
220 | osl_getModuleHandle(rtl_uString *, oslModule *pResult) | |||||
221 | { | |||||
222 | #if !defined(DISABLE_DYNLOADING) || defined(IOS) | |||||
223 | *pResult = (oslModule) RTLD_DEFAULT((void *) 0); | |||||
224 | #else | |||||
225 | *pResult = NULL__null; | |||||
226 | #endif | |||||
227 | return sal_True((sal_Bool)1); | |||||
228 | } | |||||
229 | ||||||
230 | /*****************************************************************************/ | |||||
231 | /* osl_unloadModule */ | |||||
232 | /*****************************************************************************/ | |||||
233 | void SAL_CALL osl_unloadModule(oslModule hModule) | |||||
234 | { | |||||
235 | if (hModule) | |||||
236 | { | |||||
237 | #ifndef DISABLE_DYNLOADING | |||||
238 | #ifdef ANDROID | |||||
239 | int nRet = lo_dlclose(hModule); | |||||
240 | #else | |||||
241 | int nRet = dlclose(hModule); | |||||
242 | #endif | |||||
243 | SAL_INFO_IF(do { if (true && (nRet != 0)) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "dlclose(" << hModule << "): " << dlerror()) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sal.osl"), ( "/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "244" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "dlclose(" << hModule << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "dlclose(" << hModule << "): " << dlerror(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "244" ": "), sal_detail_stream); } } } while (false) | |||||
244 | nRet != 0, "sal.osl", "dlclose(" << hModule << "): " << dlerror())do { if (true && (nRet != 0)) { if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "dlclose(" << hModule << "): " << dlerror()) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sal.osl"), ( "/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "244" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "dlclose(" << hModule << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "dlclose(" << hModule << "): " << dlerror(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "244" ": "), sal_detail_stream); } } } while (false); | |||||
245 | #endif /* ifndef DISABLE_DYNLOADING */ | |||||
246 | } | |||||
247 | } | |||||
248 | ||||||
249 | /*****************************************************************************/ | |||||
250 | /* osl_getSymbol */ | |||||
251 | /*****************************************************************************/ | |||||
252 | void* SAL_CALL | |||||
253 | osl_getSymbol(oslModule Module, rtl_uString* pSymbolName) | |||||
254 | { | |||||
255 | return (void *) osl_getFunctionSymbol(Module, pSymbolName); | |||||
256 | } | |||||
257 | ||||||
258 | ||||||
259 | /*****************************************************************************/ | |||||
260 | /* osl_getAsciiFunctionSymbol */ | |||||
261 | /*****************************************************************************/ | |||||
262 | oslGenericFunction SAL_CALL | |||||
263 | osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol) | |||||
264 | { | |||||
265 | void *fcnAddr = NULL__null; | |||||
266 | ||||||
267 | // We do want to use dlsym() also in the DISABLE_DYNLOADING case | |||||
268 | // just to look up symbols in the static executable, I think. | |||||
269 | if (pSymbol) | |||||
270 | { | |||||
271 | fcnAddr = dlsym(Module, pSymbol); | |||||
272 | SAL_INFO_IF(do { if (true && (fcnAddr == 0)) { if (sizeof ::sal:: detail::getResult( ::sal::detail::StreamStart() << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "274" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "274" ": "), sal_detail_stream); } } } while (false) | |||||
273 | fcnAddr == 0, "sal.osl",do { if (true && (fcnAddr == 0)) { if (sizeof ::sal:: detail::getResult( ::sal::detail::StreamStart() << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "274" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "274" ": "), sal_detail_stream); } } } while (false) | |||||
274 | "dlsym(" << Module << ", " << pSymbol << "): " << dlerror())do { if (true && (fcnAddr == 0)) { if (sizeof ::sal:: detail::getResult( ::sal::detail::StreamStart() << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "274" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror())); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "dlsym(" << Module << ", " << pSymbol << "): " << dlerror(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "274" ": "), sal_detail_stream); } } } while (false); | |||||
275 | } | |||||
276 | ||||||
277 | return (oslGenericFunction) fcnAddr; | |||||
278 | } | |||||
279 | ||||||
280 | /*****************************************************************************/ | |||||
281 | /* osl_getFunctionSymbol */ | |||||
282 | /*****************************************************************************/ | |||||
283 | oslGenericFunction SAL_CALL | |||||
284 | osl_getFunctionSymbol(oslModule module, rtl_uString *puFunctionSymbolName) | |||||
285 | { | |||||
286 | oslGenericFunction pSymbol = NULL__null; | |||||
287 | ||||||
288 | if( puFunctionSymbolName ) | |||||
289 | { | |||||
290 | rtl_String* pSymbolName = NULL__null; | |||||
291 | ||||||
292 | rtl_uString2String( &pSymbolName, | |||||
293 | rtl_uString_getStr(puFunctionSymbolName), | |||||
294 | rtl_uString_getLength(puFunctionSymbolName), | |||||
295 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)), | |||||
296 | OUSTRING_TO_OSTRING_CVTFLAGS(((sal_uInt32)0x0006) | ((sal_uInt32)0x0060) | ((sal_uInt32)0x0100 ) | ((sal_uInt32)0x0400) | ((sal_uInt32)0x4000)) ); | |||||
297 | ||||||
298 | if( pSymbolName != NULL__null ) | |||||
299 | { | |||||
300 | pSymbol = osl_getAsciiFunctionSymbol(module, rtl_string_getStr(pSymbolName)); | |||||
301 | rtl_string_release(pSymbolName); | |||||
302 | } | |||||
303 | } | |||||
304 | ||||||
305 | return pSymbol; | |||||
306 | } | |||||
307 | ||||||
308 | /*****************************************************************************/ | |||||
309 | /* osl_getModuleURLFromAddress */ | |||||
310 | /*****************************************************************************/ | |||||
311 | sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibraryUrl) | |||||
312 | { | |||||
313 | sal_Bool result = sal_False((sal_Bool)0); | |||||
314 | rtl_String * path = NULL__null; | |||||
315 | if (getModulePathFromAddress(addr, &path)) | |||||
316 | { | |||||
317 | rtl_uString * workDir = NULL__null; | |||||
318 | osl_getProcessWorkingDir(&workDir); | |||||
319 | if (workDir) | |||||
320 | { | |||||
321 | SAL_INFO(do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "osl_getModuleURLFromAddress: " << path->buffer) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "322" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "osl_getModuleURLFromAddress: " << path->buffer)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "osl_getModuleURLFromAddress: " << path->buffer; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "322" ": "), sal_detail_stream); } } } while (false) | |||||
322 | "sal.osl", "osl_getModuleURLFromAddress: " << path->buffer)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "osl_getModuleURLFromAddress: " << path->buffer) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "322" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "osl_getModuleURLFromAddress: " << path->buffer)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "osl_getModuleURLFromAddress: " << path->buffer; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "322" ": "), sal_detail_stream); } } } while (false); | |||||
323 | rtl_string2UString(ppLibraryUrl, | |||||
324 | path->buffer, | |||||
325 | path->length, | |||||
326 | osl_getThreadTextEncoding(), | |||||
327 | OSTRING_TO_OUSTRING_CVTFLAGS(((sal_uInt32)0x0003) | ((sal_uInt32)0x0030) | ((sal_uInt32)0x0300 ))); | |||||
328 | ||||||
329 | SAL_WARN_IF(do { if (true && (*ppLibraryUrl == 0)) { if (sizeof :: sal::detail::getResult( ::sal::detail::StreamStart() << "rtl_string2UString failed") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "330" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "rtl_string2UString failed")); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_string2UString failed"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "330" ": "), sal_detail_stream); } } } while (false) | |||||
330 | *ppLibraryUrl == 0, "sal.osl", "rtl_string2UString failed")do { if (true && (*ppLibraryUrl == 0)) { if (sizeof :: sal::detail::getResult( ::sal::detail::StreamStart() << "rtl_string2UString failed") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "330" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "rtl_string2UString failed")); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_string2UString failed"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sal.osl"), ("/usr/local/src/libreoffice/sal/osl/unx/module.cxx" ":" "330" ": "), sal_detail_stream); } } } while (false); | |||||
331 | osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl); | |||||
332 | osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl); | |||||
333 | ||||||
334 | rtl_uString_release(workDir); | |||||
335 | result = sal_True((sal_Bool)1); | |||||
336 | } | |||||
337 | else | |||||
338 | { | |||||
339 | result = sal_False((sal_Bool)0); | |||||
340 | } | |||||
341 | rtl_string_release(path); | |||||
342 | } | |||||
343 | return result; | |||||
344 | } | |||||
345 | ||||||
346 | /*****************************************************************************/ | |||||
347 | /* osl_getModuleURLFromFunctionAddress */ | |||||
348 | /*****************************************************************************/ | |||||
349 | sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress(oslGenericFunction addr, rtl_uString ** ppLibraryUrl) | |||||
350 | { | |||||
351 | return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl); | |||||
352 | } | |||||
353 | ||||||
354 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |