aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
AgeCommit message (Collapse)AuthorFilesLines
2023-03-08json_dumper: rework the error checking to improve error messages.Guy Harris2-146/+351
Fix the file name in the introductory comment. Update a comment to note that a base64 value is handled, in some ways, like a nested element, even though it's not nested in the way that an object or array is. Have json_dumper_bad() write current stack depth and the current and previous types in, if possible, symbolic or numeric form; don't dump other information. Also have it set JSON_DUMPER_FLAGS_ERROR, so no other routine needs to do so. Add routines to check for dumper stack overflow *and* underflow and report them with appropriate messages, and use them in routines that push onto or pop off of that stack, respectively. This means that the stack depth won't overflow or underflow, so we can make it unsigned (as it will never underflow below 0) and don't need to check for negative or bigger-than-the-stack values. Pull check out of json_dumper_check_state() into various existing or new routines (for common code to call in those existing routines), and have the error messages passed to json_dumper_bad() give a more detailed explanation of the particular problem detected.
2023-02-24Draft: wslog: simplify log domain tokenizeJaap Keuter1-17/+1
2023-02-13Enable rpathification and working relocation on Linux (take 3)João Valverde1-0/+39
Dumpcap depends on wsutil.so. The path to the shared library is encoded in the RPATH (or RUNPATH) property of ELF binaries. This is currently an absolute path on most Unixy systems. Dumpcap could not be made to work with a relative RPATH because it uses elevated privileges and some loaders will ignore relative RPATHs and non-standard paths under those circumstances, because of (justified) security concerns. To enable relocation of the program we link dumpcap statically with wsutil instead. This provides a fully working relocatable installation on Linux and other platforms that support relative RPATHs.
2023-02-12CMake: Check sse4.2 compiler option for x86 onlyBiswapriyo Nath1-6/+10
This prevents checking sse4.2 compiler flag in non-x86 architectures. Also set COMPILE_CAN_HANDLE_SSE4_2 and SSE4_2_FLAG variables to false and empty values respectively to skip subsequent checks.
2023-02-12Revert "Enable rpathification and working relocation on Linux (take 2)"João Valverde1-39/+0
This reverts commit 8dfe8737c554b4e4b2b48b994290a75c261e0f11
2023-02-12Enable rpathification and working relocation on Linux (take 2)João Valverde1-0/+39
Dumpcap depends on wsutil.so. The path to the shared library is encoded in the RPATH (or RUNPATH) property of ELF binaries. This is currently an absolute path on most Unixy systems. Dumpcap could not be made to work with a relative RPATH because it uses elevated privileges and some loaders will ignore relative RPATHs and non-standard paths under those circumstances, because of (justified) security concerns. To enable relocation of the program we link dumpcap statically with wsutil instead. This provides a fully working relocatable installation on Linux and other platforms that support relative RPATHs.
2023-02-12CMake: Remove unnecessary wmem object libraryJoão Valverde2-129/+77
The cmake wmem sub-library code is superfluous and adds complexity if trying to build parallel different configurations of wsutil.
2023-02-10Move ui/filter_files.[ch] to wsutilJoão Valverde3-0/+665
2023-02-10Move ui/clopts_common.[ch] to wsutilJoão Valverde3-0/+166
2023-02-10Move ui/cmdarg_err.[ch] to wsutilJoão Valverde3-0/+112
2023-02-08Replace g_utf8_make_valid() with own functionJoão Valverde4-13/+26
The function ws_utf8_make_valid() is all-around better and also does maximal substitution of subparts.
2023-02-08Make wmem and wsutil a single logical libraryJoão Valverde6-16/+11
We want to do more sophisticated processing of UTF-8 in wmem and for that we want to use the unicode utility functions in wsutil. We also want to use wmem scoped memory in wsutil unicode utility functions. This introduces a circular dependency. Fix that by making both the same library and removing the sanitary cordon separating them. We still need to be mindful of public header depencies of wmem on wsutil because wmem.h is included in wireshark.h and we want to be parsimonious with the use of global includes.
2023-02-07Move ui/version_info.[ch] to wsutilJoão Valverde3-0/+768
2023-02-07Correct function signatures for buffer functionsDavid Perry1-2/+8
2023-02-06Add a #define HAVE_MSYSTEM and use itJoão Valverde1-6/+6
In certain situations using __MINGW64__ is not correct. We want to have the condition apply using MinGW-w64 but also using MSYS2, which the __MINGW64__ condition alone does not capture. Add a HAVE_MSYSTEM C define and use it where appropriate.
2023-02-06wsutil/filesystem: Fix potential memory leakJoão Valverde1-2/+0
We now use the 'install_prefix' variable on multiple platforms, not just MSYS2.
2023-02-06Do not require using wsgcrypt.hJoão Valverde6-17/+7
The reason to use wsgcrypt.h was to wrap it around DIAG_OFF() macros and that should no longer be necessary.
2023-02-06Remove wsutil/netlink.h workaroundJoão Valverde2-66/+0
2023-02-06CMake: Cleanup unnecessary linking with shared librariesJoão Valverde3-8/+14
2023-02-06Convert unicode-utils.[ch] to 4-space indentationJoão Valverde3-109/+102
2023-02-06Move get_utf_8_string() to wsutilJoão Valverde2-0/+197
2023-01-30Revert "Enable rpathification and working relocation on Linux"Gerald Combs1-32/+0
This reverts commit 7a346c398a911a9883cc67f12542f04f87a21ee8.
2023-01-29Enable rpathification and working relocation on LinuxJoão Valverde1-0/+32
Dumpcap depends on wsutil.so. The path to the shared library is encoded in the RPATH (or RUNPATH) property of ELF binaries. This is currently an absolute path on most Unixy systems. Dumpcap could not be made to work with a relative RPATH because it uses elevated privileges and some loaders will ignore relative RPATHs and non-standard paths under those circumstances, because of (justified) security concerns. To enable relocation of the program we link dumpcap statically with wsutil instead. This provides a fully working relocatable installation on Linux and other platforms that support relative RPATHs.
2023-01-29wsutil: Filesystem routine updates.Gerald Combs2-50/+62
Make sure init_plugin_dir and get_doc_dir uses the same logic as get_datafile_dir. Update each so that the xxx_DATA_DIR and xxx_PLUGIN_DIR environment variables take precedence. CMake's ENABLE_APPLICATION_BUNDLE determines whether or not we're using an application bundle layout, so check for it instead of __APPLE__.
2023-01-26Add support for configuration path relocation on UnixJoão Valverde3-46/+51
Get the installation prefix from the program dir. We have code to obtain the directory where the executable resides for all platforms we support, Linux, BSDs, Apple, etc. On less well-known platforms where this isn't true (POSIX does not define any standard interfaces for this) we fallback on using a hard-coded installation prefix, like we have been doing until now. The path relocation allows the whole installation tree to be moved without having to recompile the program. But note there are other requirements for shared libraries to have full support for relocation. This is only partial support. We now use a header to pass the relative path definitions to avoid excessively long compilation command lines as the number of #defines increases.
2023-01-20Fix Personal Extcap folder pathJoão Valverde2-0/+29
The personal extcap folder $XDG_CONFIG_DIR/wireshark on Linux is inconsistent with the global extcap folder (lib/wireshark/extcap) and personal plugins folder (.local/lib/wireshark/plugins) and also the configuration folder should not contain architecture-specific files. The extcap personal folder is changed from: .config/wireshark/extcap to: .local/lib/wireshark/extcap
2023-01-20GUI: Ship authors as a Qt resource fileJoão Valverde1-3/+1
2023-01-20wsutil: Add get_docfile_path()João Valverde2-0/+31
2023-01-19Install documentation (HTML manuals) to DOCDIRJoão Valverde3-0/+96
Install documentation to DOCDIR instead of DATADIR. The code must be fixed to open the Help URLs from this new path. This only affects Unix-like FHS platforms. Windows installation does its own thing. Needs testing with macOS packaging.
2023-01-18AppRun: Set various pathsGerald Combs1-0/+15
Set our ld library path and our data, extcap, and plugin directories. Document WIRESHARK_EXTCAP_DIR and WIRESHARK_PLUGIN_DIR. Note that we might want to set our various directories relative to the program path.
2023-01-18CMake: Require explicit installation of development headersJoão Valverde2-0/+4
Develpment headers are a sizeable part of the binary installation and most users won't ever require them. It's recommended to package them separately in a devel package or SDK. Create a CMake installation component for development headers and add the EXCLUDE_FROM_ALL property. Headers can be installed using the invocation: cmake --install <dir> --component Development
2023-01-14MinGW: Disable -Wcast-function-type warningsJoão Valverde1-0/+2
2023-01-14MinGW: Fix warnings wiht ws_strptime()João Valverde1-17/+15
2023-01-13MinGW: Fix -Wsign-compareJoão Valverde1-3/+2
2023-01-13MinGW: Fix -Wold-style-declarationJoão Valverde1-3/+3
2023-01-13MinGW: Fix -Wstrict-prototypesJoão Valverde2-3/+3
2023-01-13MinGW: Fix -WformatJoão Valverde3-14/+14
2023-01-13MinGW: Fix -Wunused-functionJoão Valverde1-56/+0
2023-01-12MSYS2: Fix system installationJoão Valverde2-25/+109
Make the "ninja install" target in the MINGW64 shell work and allow Wireshark to run from the msys2 installation, besides the build directory. To clarify the names used here MSYSTEM is the distribution with a Linux-like environment for Windows. MINGW is the toolchain. It is possible to use MinGW without MSYS2 and we generally select the CMake variables WIN32/MSVC/MINGW/USE_MSYSTEM taking that into consideration but that WIN32+MINGW platform is not supported at the moment and it's unlikely to be supported in the near future.
2023-01-12CMake: Reverse debug macrosJoão Valverde3-15/+15
Originally WS_DISABLE_DEBUG was chosen to be similar to G_DISABLE_ASSERT and NDEBUG. However generator expressions are essential for modern CMake but the syntax is weird and having to use negations makes it ten-fold worse. Remove the negation. Instead of changing the CMake variable reverse the macro definition for WS_DISABLE_DEBUG. The $<CONFIG:cgs> generator expression with multiple config arguments requires CMake >= 3.19 so we can't use that yet for a further syntactical simplification.
2023-01-12Remove WS_DISABLE_ASSERTJoão Valverde3-19/+10
Assertions can be enabled/disabled using WS_DISABLE_DEBUG. The extra granularity afforded by WS_DISABLE_ASSERT seems unnecessary.
2023-01-11version info: Strip whitespace from a stringJoão Valverde1-1/+1
2022-12-23Add a routine to get the path of an executable given the program name.Guy Harris2-2/+40
That reduces the number of get_progfile_dir() calls, leaving only the calls that are done either to 1) get the pathname in order to display it or 2) get the pathname in order to reset the library path. That makes it easier to figure out which get_progfile_dir() calls are made to find the directory in which (non-extcap) binaries from Wireshark are installed and which - if any - are made to figure out the directory in which *the currently-running executable* are stored. (Currently, get_progfile_dir() attemps to get the former, not the latter, so extcaps in an extcap subdirectory, for example, will get the parent directory of that subdirectory, *not* the directory in which they weere installed.)
2022-12-22wsutil: Make progfile_dir the main program file directory.Gerald Combs2-1/+21
If our program file directory has a trailing "/extcap" or "\extcap", trim it off. This should let extcaps determine the proper data file and plugin directories. Fixes #15592.
2022-12-16protobuf: Do not crash on zero length bytes elementJohn Thacker2-1/+1
If a field name has been written to the json dumper for a bytes element (Base64), then a Base64 value must be written later, even if the value is zero length. Move the JSON_DUMPER_FLAGS_NO_DEBUG flag to the json_dumper header, and use it in the protobuf dissector, so that errors in the JSON dumper state transitions do not abort the application through a ws_error() call. Use DISSECTOR_ASSERT in that case, since it should happen only with a dissector bug (as with the zero bytes elements issue fixed here), not with malformed packets. Only instantiate the json_dumper and create its output string if we intend on displaying its output, instead of doing so whenever we have a message type name. Fix #18730.
2022-12-15cli: Fix copying global profile to personal at startupJohn Thacker1-23/+72
Fix up commit 1eeb0c99345701dd5698a5a36ff8f87857422b02 At initial startup, the hash of configuration files used by profiles doesn't exist yet or is not completely filled. (Files are only added to the list after initially parsing the current configuration.) So, if copying a global profile to the personal directory at initial startup, just copy all the files from the global profile. Also, don't free to_dir and from_dir if we're returning them in the case of errors.
2022-12-15wslog: Resynchronize UTF-8 displayJoão Valverde1-19/+46
When displaying the string with encoding errors resynchronize the display to print the string after the invalid substring.
2022-12-15wmem: Add wmem_strbuf_append_c_count()João Valverde3-0/+19
2022-12-15wmem: Optimize some strbuf functionsJoão Valverde1-43/+33
The changes in commit 32f88ad22c allow removing some checks that could speed up the code.
2022-12-15CMake: Disable UTF-8 debug checks for release buildsJoão Valverde1-10/+0
Disable UTF-8 debug checks for release builds for optimization purposes. Also remove unused macro that currently lacks a proper use case. Change version info to be more complete about the build type without being too verbose.