#3825: [PATCH] BUG: Fix error-checking of convert_string()
----------------------+----------------------
Reporter: flatcap | Owner: mutt-dev
Type: defect | Status: new
Priority: major | Milestone:
Component: build | Version: 1.5.24
Resolution: | Keywords: patch
----------------------+----------------------
Comment (by tamo):
I don't think your patch is necessarily correct when the return value is 1
or more.
Yes, convert_string() returns 0 on success.
But, whether 1+ is success or not depends on your definition of success.
Apparently rfc2047_encode() defines its success as 0, only 0.
That is reasonable, because the encoded string should be decoded back to
the original string.
http://man7.org/linux/man-pages/man3/iconv.3.html#RETURN_VALUE
"The iconv() function returns the number of characters converted in a
nonreversible way during this call"
https://dev.mutt.org/trac/browser/rfc2047.c#L401
"If conversion failed, fromcode is assumed to be compatible with us-ascii
and the original data is used."
So rfc2047_encode() uses the original data if conversion -- in a
reversible way -- failed.
And the code is okay, except for the leak you found.
So, what should we do?
I don't know more about leaks than you do, but
maybe we should realloc u when the return value is 1+.
Anyways, it's not safe to treat 1+ as success.
--
Ticket URL: <https://dev.mutt.org/trac/ticket/3825#comment:1>
Mutt <http://www.mutt.org/>
The Mutt mail user agent