summaryrefslogtreecommitdiffstats
path: root/lib.c
AgeCommit message (Collapse)Author
2020-11-25Surround new and old debug functions with #ifdef DEBUG.Kevin McCarthy
The new function directly references debugfile, so needs the ifdef. The old function compiles fine, but since it's not used, put it inside the ifdef too. Thanks to Ian Allen for reporting the problem.
2020-11-23add dprintf(n, fmt, ...) debugging macroDavid Champion
dprintf(n, fmt, ...) is a more natural form of dprint(n, (debugfile, fmt, ...)). It prints code location in the debug file where possible. I believe this approach, while common, was not previously used because we were trying to be C90-compatible. C90 doesn't provide variadic macros. Now we require C99, so it makes sense to add this pattern.
2020-09-06Remove unused mutt_quote_filename().Kevin McCarthy
All callers now call the buffer function instead.
2020-03-24Fix use-after-free in mutt_str_replace().Kevin McCarthy
The Outlook content-type fix in commit 4cec4b63 inadvertantly introduced a use-after-free. Calling mutt_set_parameter() pointing to a different part of the same string ends up calling mutt_str_replace() with both parameters pointing to the same hunk of memory. Improve mutt_str_replace() to deal with that case, to fix this bug and prevent possible future bugs resulting from that mistake. Thank you to Vita Batrla for the excellent bug report and patch. I merely added a comment and removed the "SAFE_FREE comment" from his patch.
2019-09-19Convert mutt_complete() to use the buffer pool.Kevin McCarthy
Add helper functions mutt_buffer_substrcpy() and mutt_buffer_concatn_path(). Remove mutt_concatn_path() because mutt_complete() was the only caller.
2019-08-03Add database and schema initialization.Kevin McCarthy
Add mutt_mkdir() library function supporting recursive mkdir.
2019-04-18Relocate lib.c functions to muttlib.c to enable BUFFER use.Kevin McCarthy
Relocate safe_symlink(), safe_open(), mutt_rmtree() and their dependent functions. This rearrangement is a bit awkward. Another approach for the future might be to convert lib.c into a muttlib.c aware file, and just copy the functions pgppubring.c uses inside itself.
2019-03-10Move mutt_rx_sanitize_string() to muttlib.cKevin McCarthy
So it can be converted to use BUFFER.
2019-01-04Clean up formatting.Kevin McCarthy
Add spaces after if, else, while, for, switch. Unify the brace placement style. The vast majority of the code uses Allman style so convert the relatively few K&R braces over.
2019-01-04Clean up code indentation.Kevin McCarthy
These are mostly automated changes corresponding to the emacs settings: (c-set-style "linux") (setq c-basic-offset 2) (c-set-offset 'case-label '+) Most of the code follows the convention: (add-to-list 'c-cleanup-list 'space-before-funcall) but this is not enforced by this indentation cleanup. Also, I personally dislike tabs, so I have: (setq-default indent-tabs-mode nil) in my own configuration. However I have no desire to change every line just for that effect. So this cleanup does nothing about the mix issue. Some of the secondary files (e.g. regex.c) have been skipped. I've also skipped crypt-gpgme.c, because I need to think about that file. Werner Koch and the GnuPG team contributed most it, and it follows the Gnu indentation settings. It should probably be made uniform with Mutt, but I don't want to discourage future GnuPG contribution to the file. I manually reverted a few unsightly cleanups, and added a few tweeks when I saw things that could be improved.
2018-12-31Remove trailing whitespace.Kevin McCarthy
The result of find . -name "*.[ch]" -exec emacs -batch {} \ --eval="(progn (delete-trailing-whitespace) (and (buffer-modified-p) (save-buffer)))" \;
2018-08-29Remove extra lstats() in safe_rename() upon link success.Kevin McCarthy
I originally kept the lstat()'s in order to make as few changes as possible to the function. However, Derek Martin argues correctly that if we are trusting the link() 0-retval, the lstats are unnecessary and in fact can cause a performance impact over NFS.
2018-08-29Add additional error handling to safe_rename().Kevin McCarthy
It is apparently possible for link() to return an error but the link to still be created. Add a double check for that case. If the files match, unlink the src and return success.
2018-08-21Remove compare_stat() call in safe_rename().Kevin McCarthy
Some filesystems, such as sshfs, implement hard links strangely. The hard link is created, but is represented by a different inode number by the sshfs layer. The current maildir code goes into an infinite loop in this case. Remove the compare_stat() and trust that a link() return code of 0 means the link really did get created. Still, keep the stats just as a minor check.
2018-08-11Add basic CONDSTORE support when fetching initial messages.Kevin McCarthy
Store MODSEQ in the header cache, and use that to perform a "FETCH CHANGEDSINCE" for header updates when initially downloading messages. Further improvements could be made to add support when syncing. Handling MODSEQ for FLAG updates while the mailbox is open would be complicated by the fact that Mutt supports locally modified headers, so we couldn't accept the new (or subsequent) MODSEQ. However, this initial step may at least provide some benefit when opening the mailbox, which is generally the most time and data intensive.
2018-06-19mutt_atol: better error handling.Vincent Lefevre
* Detect overflow on negative numbers too (< LONG_MIN). * Distinguish between format error and number overflow as already expected (e.g. for pgp_timeout and smime_timeout).
2018-06-19Reset errno to 0 before calling strtol and testing it in mutt_atol.Vincent Lefevre
Otherwise providing LONG_MAX+1 then LONG_MAX gave an error for LONG_MAX too.
2018-01-06Fix improper signed int conversion of IMAP uid and msn values.Kevin McCarthy
Several places in the imap code, when parsing "number" and "nz-number" values from the IMAP data, use atoi() and strtol(). This is incorrect, and can result in failures when a uid value happens to be larger than 2^31. Create a helper function, mutt_atoui() and use that instead. One place was using strtol() and relying on the endptr parameter, and so was changed to use strtoul() instead. Thanks to Paul Saunders for the bug report and original patch, which this commit is based on.
2016-05-09Change M_* symbols to MUTT_*Derek Martin
Changeset 23334e967dd7 created a workaround for a namespace conflict with Solaris and derivatives. After some discussion, the team decided it would be best to move away from using the "M_" prefix for macros. This patch was automatically generated by running: perl -wpi -e 's/\bM_(\w+)\b/MUTT_$1/g' `find . -name '*.[ch]' -print` with the exception that sys_socket.h was exempted. (That file will be backed out subsequent to this commit.) Thanks to Andras Salamon for supplying the perl script used to make this change.
2016-01-01Convert copyright years to all use 4 digit years.Kevin McCarthy
Vincent Lefèvre pointed out the common shortcut, e.g 1996-9, is actually not allowed for copyright years. Convert all the copyright years (for mutt files) to use 4 digits.
2016-01-01Update copyright notices.Kevin McCarthy
This patch only updates existing copyright notices in the source files, using commit dates since the last copyright update in commits e3af935cdb1a and f8fd60d8d3f2. Add a notice to the COPYRIGHT file to refer to our mercurial repository for the full commit history. Add myself to the COPYRIGHT file and smime_keys.pl file.
2015-01-26Corrected various spelling mistakes (most of them reported by codespell).Vincent Lefevre
2013-07-23fix typos in commentsOndřej Bílka
2013-03-04use mkdtemp() to create temporary directory rather than mktemp() followed by ↵is
mkdir() closes #3637
2011-12-03Declare many structures const (closes #3552)Dan Fandrich
Many structs used in mutt are actually constant but are defined without the 'const' keyword. This can slow initialization (slightly) in some environments due to extra copying and increases the amount of writable RAM required at run-time, which can be significant on non-MMU systems. Using const can also increase the opportunities for compiler optimization. The attached patch marks many such structures as const. On my test x86 build, this reduces the size of .data by over 50%.
2010-08-09rename mutt_sprintf() to safe_asprintf() to match the GNU extension that ↵Michael Elkins
performs a similar task
2010-08-08add a malloc+sprintf combo functionMichael Elkins
2009-06-22Catch range errors when converting to long.Rocco Rutte
2009-06-21mutt_read_line(): make line counting ptr optionalRocco Rutte
2009-06-15Print timestamps in debug files. Closes #3263.Rocco Rutte
2009-06-01Add mutt_atos(), mutt_atoi() and mutt_atol() (strtol() wrappers)Rocco Rutte
2009-05-29Add flags to mutt_read_line() for EOL-stripping and continuation supportRocco Rutte
We use these to stop supporting EOL-escaping with \ which was wrong in most cases (e.g. $history_file), support is kept for reading config and mailcap files. Leaving CRLF in will be used for the pager.
2009-03-15Use safe_fclose() instead of fclose(), add fclose() to check_sec.shRocco Rutte
2009-01-04Update copyrights. Closes #3016.Brendan Cully
I went through the logs of each file with a copyright header and updated the years for the authors in the headers for any non-comment changes they introduced. What a pain!
2008-10-28Make some functions static.Emanuele Giaquinta
2008-07-02Use stat() instead of dirent->d_type to test for directory. Closes #3089.Vladimir Marek
2008-07-01Support displaying application/pgp-keys with GPGME.Brendan Cully
This was pretty convoluted because GPGME provides no way to examine a key block without importing it. This code creates a temporary GPG home in which to import the key in order to display it.
2008-06-26fflush before fsync and close. Closes #2962 again.Brendan Cully
2007-12-07Check definition of ENOTSUP before use (closes #2983)Rocco Rutte
2007-10-31Fall back to rename for ENOTSUP and EOPNOTSUPP too. Closes #2975rea-mutt
2007-04-10Fix some warningsBrendan Cully
2007-04-07bug #2871Michael Elkins
Avoid altering the argument to mutt_complete() when completion fails. Previously, the trailing component of filename was removed each time the user pressed TAB.
2007-04-06safe_rename: fall back to rename on ENOSYS and EPERM as well as EXDEV.Brendan Cully
sshfs returns ENOSYS when attempting cross-directory links. vfat returns EPERM.
2007-04-06Make safe_open with O_EXCL friendlier for NFS.Brendan Cully
Per #2707, when an open file is moved into a different directory over NFS, it may leave a .nfsXXX hardlink behind. This causes the rmdir in safe_open to fail, leaving tempdir droppings around. This patch works around the problem by closing the file after creating it and reopening it after rename.
2007-03-21Back out $umask.Brendan Cully
2007-03-02Add $umask for mailboxes and attachments.Brendan Cully
init.c could really use some refactoring.
2007-01-02add debug harness to lib.c functions, and a bunch of dprint'sThomas Roessler
to safe_rename().
2006-10-09Even more paranoid temporary file creation.Thomas Roessler
2006-05-18Avoid safe_free() usage and add security checksRocco Rutte
Add checks to check_sec.sh for memory functions. These include a check for use of safe_free() instead of FREE() and a check whether FREE(&...) is used. For the former, __SAFE_FREE_CHECKED__ is to be used, for the latter __FREE_CHECKED__ to avoid messages from check_sec.sh
2005-09-17Gah, forgot the zip code when updating the FSF address...Brendan Cully