From 5382587c7885f7f1a0fa5be348e85f42003434de 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.3 --- 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 f006b40..2f539a0 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -292,6 +292,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; @@ -303,12 +307,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