Fossil

All files named ”src/util.c”
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

History for src/util.c

2025-07-07
15:11
Add a function for generating a random (v4) UUID and a test command using it. ... (file: [6d574311] check-in: [9472f708] user: danield branch: gen-uuid, size: 27966)
2025-04-16
16:22
Add the --editor option to "fossil commit" and "fossil uv edit". ... (file: [51d7aadf] check-in: [76759875] user: drh branch: trunk, size: 26830)
2025-03-19
11:08
Add "jove" to the list of text editors that Fossil searches for if the "editor" setting and the VISUAL and EDITOR environment variables are not available. ... (file: [837e0e86] check-in: [486f81b9] user: drh branch: trunk, size: 26521)
2025-03-17
12:04
Setting the text editor (either the "editor" setting, or the VISUAL or EDITOR environment variables) to "off", "no", "false", or "0" cause the use of a text editor for checkin comment entry to be bypassed. Forum post 9b613281b ... (file: [cc0f6d12] check-in: [cd03acbd] user: drh branch: trunk, size: 26507)
2025-03-16
19:15
Add the "fossil which" command, which even works on Windows. Enhance the fossil_text_editor() function so that it looks for common text editor names if it does not find a user-specified preference. ... (file: [8ced81a2] check-in: [fc60e444] user: drh branch: trunk, size: 26457)
2025-01-11
13:07
Change the previous check-in so that "2>/dev/null" is only added on unix, not on Windows or Mac. Suggested by forum post ae7ed5b615. ... (file: [9ae31611] check-in: [36bd5423] user: drh branch: trunk, size: 25156)
2024-08-27
11:06
Move the file-specific definitions of the isatty() and fileno() macros into util.c's fossil_isatty() and fossil_fileno() in prep for an upcoming change which needs isatty(). ... (file: [a390168e] check-in: [898a70ce] user: stephan branch: trunk, size: 25104)
2024-08-23
20:51
Replace calls to strcpy() with a tree-local strcpy() clone to squelch unwarranted link-time warnings when building on OpenBSD. There is still one strcpy() instance in the upstream extsrc/shell.c. ... (file: [745c823d] check-in: [c0b9b448] user: stephan branch: trunk, size: 24736)
13:05
Fix missing "return" in the new fossil_strdup_nn() routine from the previous check-in. ... (file: [ad6dc27b] check-in: [a04d1819] user: drh branch: trunk, size: 24570)
13:00
Move the fossil_strdup() implementation from import.c over to util.c where it belongs. Add a new fossil_strdup_nn() that mimics the behavior of mprintf("%s",...), only faster. ... (file: [57391f9b] check-in: [0c9dff64] user: drh branch: trunk, size: 24563)
2023-02-17
14:37
A large collection of compiler warning fixes re. signed/unsigned comparison from Daniel D. ... (file: [2779c065] check-in: [c71f711e] user: stephan branch: compiler-warnings, size: 24119)
2022-04-26
14:27
Fix a few **unused-but-set-variable** warnings. (reported by recent clang on MacOS at least). Also fix a **warn_unused_result** warning when calling nice() (gcc 7.5.0 on Ubuntu-18.04 and gcc 9.3.0 on Ubuntu-20.04) ... (file: [da69b3c5] check-in: [74250821] user: mgagnon branch: trunk, size: 24105)
2022-04-21
15:45
Changed fossil_nice_default() to use nice level 19 instead of 20, as 19 is the documented max. ... (file: [3e7d8d25] check-in: [2c892029] user: stephan branch: trunk, size: 23985)
2022-04-14
16:58
Per /chat discussion, replace load_control() calls in selective pages with nice() and move load_control() into process_one_web_page(). There is still work to do here, e.g. allowing certain pages through (namely /chat, to facilitate coordination of site defense) and perhaps checking credentials if the load is too high and always allowing admin users. ... (file: [f4daee2e] check-in: [9b0ebcaf] user: stephan branch: load-control-rework, size: 23985)
2021-12-22
15:17
Add comments to the 3 different temp-filename generator routines to cross-link them to one another. Add fossil_temp_filename() as an option to the "test-tempfile" command. ... (file: [3d241c36] check-in: [1aff4633] user: drh branch: trunk, size: 23670)
2021-09-15
19:43
Fix harmless compiler warning on Win32. ... (file: [5f0d2fcd] check-in: [e1996e25] user: mistachkin branch: trunk, size: 23611)
2021-08-31
10:39
Refactor the previous commit by adding a wrapper for `freopen()', and use the Cygwin-aware routines to convert path names to/from UTF-16. ... (file: [0db7e9c8] check-in: [963de841] user: florian branch: win32-temppath-mojibake, size: 23611)
07:01
On Windows, make sure temporary path names containing non-ASCII characters are accessible, for example if the default temporary path "C:\Users\«Username»\AppData\Local\Temp" contains a user name with extended characters, of if the %TEMP% environment variable points to a directory name with extended characters. ... (file: [673d1b54] check-in: [10233982] user: florian branch: win32-temppath-mojibake, size: 23617)
2021-08-28
16:36
Further improvements to fossil_temp_filename() to help ensure that the correct directory separators are used on both unix and windows. ... (file: [5d3a4d94] check-in: [5434d2e3] user: drh branch: trunk, size: 23329)
15:46
More robust implementation of fossil_temp_filename that does not require an open connection to a real database. ... (file: [12e1e290] check-in: [93969666] user: drh branch: trunk, size: 23146)
2021-08-27
11:29
Fix the goofy non-quoting of URL arguments to "start" on windows by including an extra quoted empty term. Forum post 9600b10ffd0a7483. ... (file: [ea2c3755] check-in: [0d8c9288] user: drh branch: trunk, size: 22458)
2021-08-07
17:28
Improved error message upon timeout. Combine redundant implementations of the function that finds user and kernel CPU usage. ... (file: [b395caf6] check-in: [6c3d3704] user: drh branch: trunk, size: 22453)
2021-06-24
16:40
Improvements to comments on the filename shell quoting logic and test logic. No changes to code. ... (file: [333d90cb] check-in: [255a28b3] user: drh branch: trunk, size: 22454)
16:31
Improvements to command-line safety checks for Windows. Enhance the command-line argument quoting fuzzer to inject all kinds of multi-byte UTF-8 characters. ... (file: [63b4f26b] check-in: [6d2e48b4] user: drh branch: trunk, size: 22437)
2021-06-22
17:28
There is a fossil_spawn() implementation for windows here, using _wspawnvp(). But it does not work. Apparently _wspawnvp() does not preserve the argument boundaries. ... (file: [85992315] check-in: [be6aa9e6] user: drh branch: demo-windows-wspawn-error, size: 24796)
07:56
Constness fix to the new fossil_spawn() function to avoid compiler complaints on current macOS. ... (file: [21da6c2f] check-in: [eefb8e64] user: wyoung branch: fossil-spawn, size: 24011)
2021-06-21
22:37
Created fossil_spawn() as a dumb-as-rocks wrapper for posix_spawnp(2) and created tests to prove that it doesn't double-interpret its args as fossil_system() does. This isn't portable yet; it's just a seed we can use to bring this branch to a PoC state. ... (file: [15f68d2a] check-in: [fb7c5797] user: wyoung branch: fossil-spawn, size: 24010)
13:53
Add the "fossil bisect run" command. ... (file: [1fbe5a05] check-in: [7d4cf0ed] user: drh branch: trunk, size: 22558)
12:35
In the test-fossil-system command, show the result code coming back from each command. ... (file: [d731cfbf] check-in: [f6b67e15] user: drh branch: trunk, size: 21907)
2021-03-25
01:32
Reduce fossil_panic() calls to those indicating bugs and internal errors. Also clarify effects and purposes of fossil_fatal() vs. fossil_panic(). ... (file: [cc4ade16] check-in: [91a4652f] user: larrybr branch: panic-reduction, size: 21858)
2021-01-27
13:32
More TH1 performance optimizations: Go directly to malloc() rather than through the Th_Malloc() intermediary. ... (file: [0ab50075] check-in: [9b4f2d8e] user: drh branch: trunk, size: 21858)
2021-01-07
20:48
Show the resident set size (RSS) on the /test_env page. ... (file: [9dd3ee76] check-in: [b00e20c7] user: drh branch: trunk, size: 21711)
2021-01-03
16:40
Use the "plunk" sound for audiable alert in chat. Back out the "ping" processing logic. ... (file: [5cb7845c] check-in: [f2fcdbc5] user: drh branch: trunk, size: 21504)
2021-01-02
12:58
Improvements to the test-random-password command. ... (file: [d3c6aa0b] check-in: [931b97e8] user: drh branch: trunk, size: 20135)
2020-08-21
23:20
Rework forum post serial IDs to include a revision number when edited. This fixes buggy sids displayed in thread https://fossil-scm.org/forum/forumpost/6737a387fe?t=c&threadtable. ... (file: [65c28c9c] check-in: [dd47b8c3] user: andygoth branch: andygoth-forum-refactor, size: 19474)
2020-06-09
23:32
Improvements to fossil_assert_safe_command_string(), especially for windows. ... (file: [de0723ef] check-in: [ce16c594] user: drh branch: trunk, size: 19141)
17:32
Improvements to command-string sanitizing and the the sanitizer test command. ... (file: [6ad3d431] check-in: [e3185aee] user: drh branch: safe-fossil-system-test, size: 18878)
16:47
Begin splitting up fossil_assert_safe_command_string() into separate windows and unix implementions. Add the test-fossil-system command for testing. ... (file: [33335ba5] check-in: [9c38a004] user: drh branch: safe-fossil-system-test, size: 17910)
00:38
Allow '&' as the last character in a fossil_system() string. ... (file: [850cb989] check-in: [84346a31] user: drh branch: trunk, size: 17366)
2020-06-08
23:37
Add a safety scan of all strings passed into fossil_system(). Fatal error if the input string seems unsafe. ... (file: [ed308b4e] check-in: [a046f916] user: drh branch: trunk, size: 17259)
2020-05-27
22:14
Updated all user-facing documentation and "fossil help" output (plus select internal comments and function names) to use "hash" rather than "UUID". No functional changes. (Yet?) See forum thread https://www.fossil-scm.org/forum/forumpost/ddc14c6866 for discussion. ... (file: [b774c152] check-in: [df520195] user: wyoung branch: uuid-to-hash, size: 15728)
2020-04-23
18:36
Begin adding the ability to restrict self-registration to people with a particular email address pattern. This check-in provides the setting to specify the authorized email addresses, but an attacker can still lie about his email address and sneak in that way. Still a work-in-progress. ... (file: [ba9c17c6] check-in: [7916dbaa] user: drh branch: restricted-self-registration, size: 15719)
2020-04-05
23:45
Match the COMMAND and WEBPAGE names with _cmd and _page functions; forumpost/045bffda68 ... (file: [ded7fa20] check-in: [06afb702] user: ashepilko branch: api-cleanup, size: 15456)
2019-09-10
11:30
Performance optimization in fossil_strcmp(). ... (file: [907ebfaf] check-in: [72a4b613] user: drh branch: trunk, size: 15452)
2019-08-23
12:42
Add the fossil_random_password() utility function and use it to generate a stronger initial admin-user password in the "fossil new" command. ... (file: [28a9c1dd] check-in: [23a9f9ba] user: drh branch: trunk, size: 15560)
2018-07-15
19:56
Clarify the difference between fossil_fatal() and fossil_panic(). The fossil_panic() interface puts a message on the error log when generating webpages. Otherwise the two routines are identical. Convert some fossil_fatal() calls into fossil_panic() where appropriate. The goal here is to limit messages on the error log to things that require attention from the system administrator, or represent bugs. ... (file: [8c7d4b56] check-in: [3f5ab717] user: drh branch: trunk, size: 14086)
2018-07-13
21:36
Improved process debugging for "fossil ui" and "fossil server". Sanely close the open database connection upon receiving SIGPIPE. ... (file: [49632b48] check-in: [83b171bc] user: drh branch: trunk, size: 14086)
2018-03-17
22:33
Merge updates from trunk. ... (file: [74d0258c] check-in: [5447bc90] user: mistachkin branch: withMman, size: 13942)
22:32
Fix harmless compiler warning. ... (file: [a633e660] check-in: [e2a90ed5] user: mistachkin branch: trunk, size: 13358)
21:16
POSIX enhancements for fossil_get_page_size(). ... (file: [f7610cb5] check-in: [fd1bee72] user: mistachkin branch: withMman, size: 13938)
20:31
Experimental support for using 'mman.h' when compiling for POSIX. ... (file: [c61345cf] check-in: [37b69e7d] user: mistachkin branch: withMman, size: 13843)
2018-03-07
19:46
Rid the code of the legacy UUID_SIZE macro. Replace it everywhere with either HNAME_MAX or HNAME_LEN_SHA1 or HNAME_LEN_K256, as appropriate. ... (file: [a9ee84f1] check-in: [323299cb] user: drh branch: trunk, size: 13354)
2018-01-17
19:29
Only make the first argument to pledge() available using the fossil_pledge() interface. The second argument is always NULL. ... (file: [c4d7bb8b] check-in: [91ccde50] user: drh branch: trunk, size: 13296)
19:04
Automatically detect the presence of the pledge() system interface and use it if it is available. ... (file: [220c7023] check-in: [64def88f] user: drh branch: trunk, size: 13350)
2018-01-15
21:50
Remove unnecessary whitespace. ... (file: [d3a811d4] check-in: [73d0734a] user: andybradford branch: mistake, size: 13364)
21:48
Update the comment for fossil_pledge to reflect the new change in [1180676e]. ... (file: [0b1ad26c] check-in: [8993c332] user: andybradford branch: trunk, size: 13365)
21:43
Only #define fossil_pledge in config.h if FOSSIL_HAVE_PLEDGE is not defined so that makeheaders can pick up the function prototype for checkin.h when FOSSIL_HAVE_PLEDGE is defined. ... (file: [4ca8629c] check-in: [1180676e] user: andybradford branch: trunk, size: 13364)
17:35
End comment with matching #define for new fossil_pledge_impl() routine---no functional change. ... (file: [c9a07aa8] check-in: [cefcc87e] user: andybradford branch: trunk, size: 13369)
16:18
Add the fossil_pledge() utility routine, that is a no-op unless compiled with FOSSIL_HAVE_PLEDGE. ... (file: [f537e969] check-in: [7b81a999] user: drh branch: trunk, size: 13362)
2017-12-15
18:27
Remove pointless code that initializes a BSS data structure to zeros, even though it is already all-zero. This avoids a compiler warning in GCC7. ... (file: [89f917cf] check-in: [5419e7fc] user: drh branch: trunk, size: 12829)
2017-06-24
16:28
Fixed "integer constant is too large for long type" warning on 32-bit Linux ... (file: [58828762] check-in: [caf26817] user: andygoth branch: trunk, size: 12952)
13:59
Increase the stack size limit to 8MB. Disable stack and heap size limits prior to invoking subprocesses. ... (file: [2634b301] check-in: [3f193ba6] user: drh branch: trunk, size: 12944)
2017-06-20
13:35
On unix, use setrlimit() to limit total heap space usage to 1GB on 32-bit systems and 10GB on 64-bit systems, and total stack space to 2MB, as a proactive defense again the "stack clash" vulnerability found on many unix-like OSes. I do not yet know if these limits are reasonable. ... (file: [ae9317b0] check-in: [6e6e4b1d] user: drh branch: trunk, size: 12452)
2016-10-04
19:05
Add an assert(). ... (file: [9a3cc502] check-in: [e6a5634f] user: mistachkin branch: seeEnhanced, size: 11784)
2016-09-23
02:28
Merge updates from trunk. ... (file: [72608920] check-in: [4f619c02] user: mistachkin branch: seeEnhanced, size: 11757)
2016-08-24
14:56
Unbreak compilation on Cygwin. Allow notepad to be used as unversioned content editor (notepad cannot handle UNIX line-endings) ... (file: [08c5fc01] check-in: [6728970b] user: jan.nijtmans branch: trunk, size: 10319)
2016-08-23
13:01
Add the "fossil unversioned edit UVFILE" command. ... (file: [cad066de] check-in: [1d6b6782] user: drh branch: trunk, size: 10345)
2016-05-28
21:23
Enhancements to SEE integration. ... (file: [2b396c37] check-in: [4e34191c] user: mistachkin branch: seeEnhanced, size: 10602)
2015-01-21
18:55
Enhance the ad-unit processing to allow for tall right-side column ads as an alternative to banner ads. ... (file: [9f02b013] check-in: [4bc5b6cf] user: drh branch: ad-unit-enhancement, size: 9164)
2014-10-21
09:27
merge trunk ... (file: [e515fb32] check-in: [154abe4d] user: baruch branch: svn-import, size: 8932)
09:22
Very very basic svn-dump import. Can not handle anything realistic yet ... (file: [8c956791] check-in: [287cd78e] user: baruch branch: svn-import, size: 8571)
2014-10-06
00:58
Add an assert() to prove that Fossil server instances are not vulnerable to the ShellShock bug because it never shells-out while processing an HTTP request. ... (file: [227890c0] check-in: [82e30c00] user: drh branch: trunk, size: 8919)
2014-08-07
10:02
"char const" -> "const char" and various other coding style improvements. No functional change. ... (file: [d776ecab] check-in: [4e18dba6] user: jan.nijtmans branch: trunk, size: 8558)
2014-04-11
15:44
Refactored ATTACHMENT crosslinking a bit to remove some duplicate code (tested on libfossil repo). Replaced free() with fossil_free() (consistency). Added fossil_is_uuid(), the c-string counterpart of blob_is_uuid(). ... (file: [369a0bac] check-in: [b7ff537d] user: stephan branch: trunk, size: 8559)
2013-09-19
11:48
Fix MSVC build error and warnings: c:\localdata\workspace\fossil\src\util.c(249) : warning C4715: 'fossil_timer_fetch' : not all control paths return a value c:\localdata\workspace\fossil\src\util.c(270) : warning C4715: 'fossil_timer_reset' : not all control paths return a value ... (file: [70545101] check-in: [6e1e4bb8] user: jan.nijtmans branch: trunk, size: 8314)
2013-08-30
12:18
Add the --errorlog command-line option and the errorlog: parameter to CGI scripts. Log all panics, fatal errors, and warnings to the error log, if defined. Panic if file descriptor 2 is not open on unix. Clean up some routines that deal with close(). ... (file: [a2369fb9] check-in: [4727ef4a] user: drh branch: trunk, size: 8330)
2013-05-13
10:50
unused variable "fossilTimer" ... (file: [d31f9b92] check-in: [55d7e2c1] user: jan.nijtmans branch: trunk, size: 8016)
2013-05-08
20:18
Fixed a logic error in the only-run-once timer init code. ... (file: [a20136c9] check-in: [9fab0f81] user: stephan branch: trunk, size: 8100)
20:09
Reworked the timer IDs to be positive values to simplify error checking a bit. ... (file: [445d4421] check-in: [79945897] user: stephan branch: trunk, size: 8086)
19:54
Added fossil_timer_is_active(timerId), removed fossil_has_timer(). ... (file: [09d63130] check-in: [590406df] user: stephan branch: trunk, size: 7911)
19:45
Added fossil_timer_xxx() family of functions and g.mainTimerId. ... (file: [68ce2361] check-in: [e28433a6] user: stephan branch: trunk, size: 7725)
2013-02-21
15:50
Make win32 build compile again: - missing headers <io.h> and <fcntl.h> - WCHAR -> wchar_t ... (file: [40229a2f] check-in: [e3add2c1] user: jan.nijtmans branch: trunk, size: 3260)
14:24
Code refactoring: Move utility routines (ex: fossil_malloc()) out of main.c and into a new file util.c. Try to gather I/O routines into the printf.c source file. ... (file: [bb167adb] check-in: [bb0cedb1] user: drh branch: trunk, size: 3258)