summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2011-01-17 21:37:58 +0000
committerJim Jagielski <jim@apache.org>2011-01-17 21:37:58 +0000
commitbdcda65b1418114a65d76bfc3313c4afaf6840fa (patch)
tree3178233731f0f6abaaa4f8c7d06d4157acc217b2 /strings
parent85a08e8c9da0791235d2c8a47d417ef4997226b0 (diff)
downloadapr-bdcda65b1418114a65d76bfc3313c4afaf6840fa.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: https://svn.apache.org/repos/asf/apr/apr/trunk@1060104 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 &&