summaryrefslogtreecommitdiffstats
path: root/lib.h
AgeCommit message (Collapse)Author
2021-09-23Don't use subtraction for qsort numeric value comparisons.Kevin McCarthy
Subtraction can overflow, resulting in incorrect sorts. This is especially a concern for the date and size sorting, whose fields are greater than an 'int' size. The index values should be okay, but it's better to be consistent and avoid any possible issues. Define a macro, mutt_numeric_cmp(), that uses direct comparison rather than subtraction.
2021-07-22Use memccpy() in the strfcpy macro if it's available.Kevin McCarthy
Thanks to Ian Collier for making this suggestion! It's more efficient and disables unhelpful compiler warnings about strncpy(), since strfcpy is terminating the string itself. If memccpy() is unavailable, use strncpy() but keep the old behavior of strncpy() length C instead of C-1, as I believe it tickles less compiler warnings. Add parenthesis around macro parameter uses, to be safe. Thanks to Vincent Lefèvre for pointing that out.
2021-05-01Add allow_8bit flag to sanitize_filename functions.Kevin McCarthy
This will allow "view" mailcap invocations and autoview invocations to display something reasonable for international file names. Also add the flag to mutt_adv_mktemp(), which the mailcap viewer calls. Convert the 'slash parameter' to an ALLOW_SLASH flag. This makes the flags consistent (both "allow" something not permitted by default), and invocations more readable.
2021-02-18Update gettext to version 0.21.Kevin McCarthy
Run 'gettextize -f --no-changelog' to update to 0.21. This removes the entire intl directory, and relies on an external libintl only. $(INTLLIBS) should now be referred to as $(LIBINTL), so change all references. Unfortunately, some of the gettext m4 files were modified and "mutt customized" in the past. I'm trying to keep them in a pristine state after this upgrade. glibc21.m4, lcmessage.m4, codeset.m4 have also been removed. Manually call AM_ICONV in configure.ac. This was previously called in the modified "MUTT_AM_GNU_GETTEXT" but the result $am_cv_func_iconv is tested just below. locale.h is a standard library defined by C99. The gpgme and pgp code wrapped those includes in HAVE_LOCALE_H checks, but that check was performed inside of gettext.m4. Remove the check inside those files (locale.h is already included unconditionally elsewhere in Mutt). Copy the sample gettext.h file and include that instead, as suggested by the gettext documentation. unistd.h is also a standard posix header, so remove HAVE_UNISTD_H checks inside mutt too. Create po/LINGUAS file listing available languages. Create po/Makevars from the template and customize for Mutt. Set PO_DEPENDS_ON_POT to no to prevent po file rebuilds. According to the gettext manual, with this set, "PO files can be accidentally updated even if a POT file is not updated" when using git.
2021-01-27Convert all mutt_atoX functions to behave strictly.Kevin McCarthy
* Remove the automatic conversion of NULL and '\0' to 0. Add a flag for the cases that require lax evaluation. * Make trailing characters generate an error by default for the mutt_atouX functions. Add a flag for that case. Most of the IMAP code parses numbers out of a stream, so add the flag to those calls. * The mutt_atouX functions were also behaving incorrectly with invalid input, e.g. "ABC", returning and setting 0. Fix them to return an error in those cases. * Add a mutt_atoll() function, to be used in the next commit. * Change converters to store 0 on error. atos, atoi, and atoui were already doing this, but the others were not.
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.
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-06-21Remove NULL and 0 INITVAL declarataions.Kevin McCarthy
The C standard says static storage duration variables will be initialized to NULL/0.
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.
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-09-30Increase buffer sizes for some IMAP commands.Kevin McCarthy
Use to ensure assembled IMAP commands fit in the resultant buffer to be imap_exec()'ed. RFC2683 suggested a limit of 1000, but asked servers to accept up to 8000. Furthermore, RFC7162 bumped the client limit suggestion up to 8192. So I don't believe any issues will be caused by this. Most of these are increases are just to remove theoretical truncation warned about by the compiler; I don't believe we've had reports of actual command truncation due to a mailbox 1024 characters long.
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-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-11-29Add mutt_array_size macro, change interactive_check_cert() to use it. (see ↵Kevin McCarthy
#3899) While I have reservations about the construct, it does make the interactive_check_cert() menu->max and part loop less fragile.
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-23Increase HUGE_STRING size to 8192. (see #3804)Kevin McCarthy
The interface for editing a large number of recipients is poor and perhaps shouldn't be using a fixed buffer size. Until a redesign can be thought about, this will help.
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-11-09Fix possible unintentional '\0' strchr matches.Kevin McCarthy
After fixing the ticket 3787 strchr issue, this patch cleans up other potentially incorrect uses of strchr for the '\0' case. In mutt_multi_choice(), mutt_getch() can technically return 0. Although it seems the user would have to try quite hard to do this, it's incorrect to return that index into letters. Change "ch.ch==0" to be considered the same as an abort. is_email_wsp() is used in a couple places where it wasn't obvious whether '\0' was being accounted for, so add an explicit check to the function. Inside eat_date(), if mutt_extract_token() had no input and returned "", the strchr ("<>=", buffer.data[0]) below would return a pointer. In actuality, this is prevented by an empty parameter check inside mutt_pattern_comp(), but it doesn't hurt to make it the same as eat_regexp() and have the check explicitly done here too. rfc2047_encode() was another borderline case for adding a check. The convert_string() sets a length, so it seems highly unlikely that *t could be 0, but doesn't hurt to add the check. The find_encoded_word() fix looks necessary. If the passed in s was something like "=?charset?" (followed by EOS, '\0'), the strchr("BbQq", q[1]) would in fact return a pointer and the following q[2] would read past the end of string. If q[2] happened to be '?', it might even continue reading in the for loop below. Lastly, in parse_mailboxdomain(), the potential overread was already fixed in changeset:a6919571eb59, but although the nonspecial and special strchr() line happens to "work" for the case of '\0', it's pretty fragile to leave as is. It's better to be explicit and just return if we hit EOS without calling next_token().
2012-12-18rename iswsp() to is_email_wsp()Michael Elkins
add new inline funtion skip_email_wsp() to be used in lieu of SKIPWS() when parsing ASCII protocols rather than user input. change use of SKIPWS() to skip_email_wsp() in places where it is likely to be a problem.
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
2010-08-06Resolve if/else empty body ambiguity/warnings when compiling without DEBUG.Matthias Andree
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-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-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-11-20Alternate fix for not calling bind_textdomain_codeset() to fix Solaris build.Rocco Rutte
2007-11-15Don't use bind_textdomain_codeset() if we're not using NLS/gettext. Closes ↵peb
#2162.
2007-08-28Use limits.h for PATH_MAX instead of posix1_lim.h (closes #2525)Brendan Cully
2007-07-08This patch implements the "%* " notation, which is analogous to "%> "David Champion
but gives precedence to the right side instead of to the left when the fill length is zero. The default $pager_format is updated to use it so that %P is always available at the edge of the screen.
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-01-02add debug harness to lib.c functions, and a bunch of dprint'sThomas Roessler
to safe_rename().
2005-09-17Gah, forgot the zip code when updating the FSF address...Brendan Cully
2005-09-17Update FSF address (via sed, I hope nothing got mangled). Closes: #2071.Brendan Cully
2005-08-06Report non-zero exit status of tunnel command. Closes: #1749.Brendan Cully
2005-02-05Remove a number of unnecessary config.h includes, and add someThomas Roessler
missing ones. May fix some bugs.
2004-10-30safe_strcat, safe_strncat. Thanks to Ulf H. for noting the wrongThomas Roessler
use of strncat in part of the mutt code base.
2003-10-04This patch fixes various aspects of the attachment-savingThomas Roessler
user interface. Changes include: * When tagging and saving multiple attachments, you can now use the same target directory for multiple attachments. * When you can't save an attachment, you get an opportunity to enter a new file name. * The menu cursor will highlight the attachment that you are currently discussing with mutt. * Various bug fixes. This does, in particular, address #1619 (Debian#208430).
2003-09-19As the ones of you who compile with new gcc's probably have noticed,Mads Martin Joergensen
there's a lot of type-punning in Mutt. With help from Philipp Thomas, I've fixed all I could find in CVS (please double-check, one might have slipped through the cracks), I can make one for 1.4 CVS branch as well if wanted.
2002-12-11Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> notesThomas Roessler
that mutt may currently build IMAP URLs like imap://exchange//herbert for FCCs. The fix in this patch is to include a function named mutt_concat_path which concatenates path elements, but avoids the creation of double slashes. (These don't create problems when you're just accessing the file system, but apparently thy do cause problems with IMAP.)
2002-12-11Fix Mike's and my e-mail addresses in copyright lines.Thomas Roessler
2002-04-29Fix #1171.Thomas Roessler
2002-02-06Avoid a warning on some machines.Thomas Roessler
2002-02-06Make some scanf formats safe.Thomas Roessler