summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorjim <jim@13f79535-47bb-0310-9956-ffa450edef68>2011-01-17 21:38:08 +0000
committerjim <jim@13f79535-47bb-0310-9956-ffa450edef68>2011-01-17 21:38:08 +0000
commit8621194d74178fbc856388ef895827dde1a0aa6f (patch)
treec6b4cd96f843a4b06c2d26986b95a4f639d2ddbb /strings
parent7a87333aafa4006f94ec00a8155b22e0439fbe77 (diff)
downloadlibapr-8621194d74178fbc856388ef895827dde1a0aa6f.tar.gz
Fix cases where off_t (and APR_OFF_T_FMT) may be "larger" than
int64 (and APR_INT64_T_FMT). git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1060105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r--strings/apr_snprintf.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/strings/apr_snprintf.c b/strings/apr_snprintf.c
index 013100799..695739480 100644
--- a/strings/apr_snprintf.c
+++ b/strings/apr_snprintf.c
@@ -810,10 +810,27 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *),
adjust_precision = adjust_width = NO;
/*
- * Modifier check. Note that if APR_INT64_T_FMT is "d",
- * the first if condition is never true.
+ * Modifier check. In same cases, APR_OFF_T_FMT can be
+ * "lld" and APR_INT64_T_FMT can be "ld" (that is, off_t is
+ * "larger" than int64). Check that case 1st.
+ * Note that if APR_OFF_T_FMT is "d",
+ * the first if condition is never true. If APR_INT64_T_FMT
+ * is "d' then the second if condition is never true.
*/
- if ((sizeof(APR_INT64_T_FMT) == 4 &&
+ if ((sizeof(APR_OFF_T_FMT) > sizeof(APR_INT64_T_FMT)) &&
+ (sizeof(APR_OFF_T_FMT) == 4 &&
+ fmt[0] == APR_OFF_T_FMT[0] &&
+ fmt[1] == APR_OFF_T_FMT[1]) ||
+ (sizeof(APR_OFF_T_FMT) == 3 &&
+ fmt[0] == APR_OFF_T_FMT[0]) ||
+ (sizeof(APR_OFF_T_FMT) > 4 &&
+ strncmp(fmt, APR_OFF_T_FMT,
+ sizeof(APR_OFF_T_FMT) - 2) == 0)) {
+ /* Need to account for trailing 'd' and null in sizeof() */
+ var_type = IS_QUAD;
+ fmt += (sizeof(APR_OFF_T_FMT) - 2);
+ }
+ else if ((sizeof(APR_INT64_T_FMT) == 4 &&
fmt[0] == APR_INT64_T_FMT[0] &&
fmt[1] == APR_INT64_T_FMT[1]) ||
(sizeof(APR_INT64_T_FMT) == 3 &&