mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Merge remote-tracking branch 'tor-github/pr/1054' into maint-0.3.5
This commit is contained in:
commit
1ba2bd3599
6
changes/bug30561
Normal file
6
changes/bug30561
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
o Minor bugfixes (portability):
|
||||||
|
- Avoid crashing in our tor_vasprintf() implementation on systems that
|
||||||
|
define neither vasprintf() nor _vscprintf(). (This bug has been here
|
||||||
|
long enough that we question whether people are running Tor on such
|
||||||
|
systems, but we're applying the fix out of caution.) Fixes bug 30561;
|
||||||
|
bugfix on 0.2.8.2-alpha. Found and fixed by Tobias Stoeckmann.
|
@ -131,14 +131,24 @@ tor_vasprintf(char **strp, const char *fmt, va_list args)
|
|||||||
* characters we need. We give it a try on a short buffer first, since
|
* characters we need. We give it a try on a short buffer first, since
|
||||||
* it might be nice to avoid the second vsnprintf call.
|
* it might be nice to avoid the second vsnprintf call.
|
||||||
*/
|
*/
|
||||||
|
/* XXXX This code spent a number of years broken (see bug 30651). It is
|
||||||
|
* possible that no Tor users actually run on systems without vasprintf() or
|
||||||
|
* _vscprintf(). If so, we should consider removing this code. */
|
||||||
char buf[128];
|
char buf[128];
|
||||||
int len, r;
|
int len, r;
|
||||||
va_list tmp_args;
|
va_list tmp_args;
|
||||||
va_copy(tmp_args, args);
|
va_copy(tmp_args, args);
|
||||||
/* vsnprintf() was properly checked but tor_vsnprintf() available so
|
/* Use vsnprintf to retrieve needed length. tor_vsnprintf() is not an
|
||||||
* why not use it? */
|
* option here because it will simply return -1 if buf is not large enough
|
||||||
len = tor_vsnprintf(buf, sizeof(buf), fmt, tmp_args);
|
* to hold the complete string.
|
||||||
|
*/
|
||||||
|
len = vsnprintf(buf, sizeof(buf), fmt, tmp_args);
|
||||||
va_end(tmp_args);
|
va_end(tmp_args);
|
||||||
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
if (len < 0) {
|
||||||
|
*strp = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (len < (int)sizeof(buf)) {
|
if (len < (int)sizeof(buf)) {
|
||||||
*strp = tor_strdup(buf);
|
*strp = tor_strdup(buf);
|
||||||
return len;
|
return len;
|
||||||
|
Loading…
Reference in New Issue
Block a user