From 0f76edd88936fc2d98607e7b4cb29d8415bd4104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 4 Jun 2007 22:51:41 +0000 Subject: [PATCH] (quote_string): don't sign extend the (signed) char to avoid printing too much, add an assert to check that we didn't overrun the buffer. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20891 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/name.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hx509/name.c b/lib/hx509/name.c index 24275217e..5456bd620 100644 --- a/lib/hx509/name.c +++ b/lib/hx509/name.c @@ -82,11 +82,12 @@ quote_string(const char *f, size_t len, size_t *rlen) to[j++] = from[i]; } else { int l = snprintf(&to[j], tolen - j - 1, - "#%02x", (unsigned int)from[i]); + "#%02x", (unsigned char)from[i]); j += l; } } to[j] = '\0'; + assert(j < tolen); *rlen = j; return to; }