summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/printf-pos.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2009-02-28 04:58:18 +0000
committerdas <das@FreeBSD.org>2009-02-28 04:58:18 +0000
commit8f720cc6670287f3dc8e001fd7373042cb85e875 (patch)
treec6a4ad3e40ffcac2f78ac97d44380a78e031021d /lib/libc/stdio/printf-pos.c
parentddd5c68e843d2a001ea8e2dea8a1df60e8b9c96f (diff)
downloadFreeBSD-src-8f720cc6670287f3dc8e001fd7373042cb85e875.zip
FreeBSD-src-8f720cc6670287f3dc8e001fd7373042cb85e875.tar.gz
Make sure %zd treats negative arguments properly on 32-bit platforms.
Fix harmless but related bugs in %_$zd and %_$tu. PR: 131880 MFC after: 1 week
Diffstat (limited to 'lib/libc/stdio/printf-pos.c')
-rw-r--r--lib/libc/stdio/printf-pos.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index 945ba61..351bed5 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$");
enum typeid {
T_UNUSED, TP_SHORT, T_INT, T_U_INT, TP_INT,
T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG,
- T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET,
+ T_PTRDIFFT, TP_PTRDIFFT, T_SSIZET, T_SIZET, TP_SIZET,
T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR,
T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR
};
@@ -145,7 +145,7 @@ addsarg(struct typetable *types, int flags)
if (flags & INTMAXT)
types->table[types->nextarg++] = T_INTMAXT;
else if (flags & SIZET)
- types->table[types->nextarg++] = T_SIZET;
+ types->table[types->nextarg++] = T_SSIZET;
else if (flags & PTRDIFFT)
types->table[types->nextarg++] = T_PTRDIFFT;
else if (flags & LLONGINT)
@@ -168,7 +168,7 @@ adduarg(struct typetable *types, int flags)
else if (flags & SIZET)
types->table[types->nextarg++] = T_SIZET;
else if (flags & PTRDIFFT)
- types->table[types->nextarg++] = T_PTRDIFFT;
+ types->table[types->nextarg++] = T_SIZET;
else if (flags & LLONGINT)
types->table[types->nextarg++] = T_U_LLONG;
else if (flags & LONGINT)
@@ -716,6 +716,9 @@ build_arg_table(struct typetable *types, va_list ap, union arg **argtable)
case T_SIZET:
(*argtable) [n].sizearg = va_arg (ap, size_t);
break;
+ case T_SSIZET:
+ (*argtable) [n].sizearg = va_arg (ap, ssize_t);
+ break;
case TP_SIZET:
(*argtable) [n].psizearg = va_arg (ap, size_t *);
break;
OpenPOWER on IntegriCloud