From 69673e76e7ac8f195a872c7753ba7cc5cd139eed Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 18 Jun 2010 09:28:11 +0200 Subject: [PATCH] snprintf() fixes, for version 4.3.4 --- src/libstrongswan/utils/identification.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index 10daf46..85925e0 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -300,6 +300,10 @@ static void dntoa(chunk_t dn, char *buf, size_t len) { written = snprintf(buf, len,"%s=", oid_names[oid].name); } + if (written < 0 || written >= len) + { + break; + } buf += written; len -= written; @@ -311,12 +315,20 @@ static void dntoa(chunk_t dn, char *buf, size_t len) { written = snprintf(buf, len, "%#B", &data); } + if (written < 0 || written >= len) + { + break; + } buf += written; len -= written; if (data.ptr + data.len != dn.ptr + dn.len) { written = snprintf(buf, len, ", "); + if (written < 0 || written >= len) + { + break; + } buf += written; len -= written; } -- 1.7.0.4