From 747b3d8b0e045edb166738ecde99dcc951212988 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Ganne?= Date: Wed, 21 Aug 2019 18:27:23 +0200 Subject: [PATCH] vcl: fix ldp_set_app_name overflow MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In case of overflow, we null-terminate the parameter ('app_name') instead of ldp global name ('ldp->app_name'). Moreover, snprintf() always safely null-terminate the destination string even in case of overflow. Type: fix Fixes: 048b1d6ab7 Change-Id: I4d8b0e020a228e982b6699d652b341c5afe92993 Signed-off-by: Benoît Ganne --- src/vcl/ldp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c index 70a4299083e..7aa38305249 100644 --- a/src/vcl/ldp.c +++ b/src/vcl/ldp.c @@ -132,11 +132,8 @@ ldp_worker_get_current (void) static inline void ldp_set_app_name (char *app_name) { - int rv = snprintf (ldp->app_name, LDP_APP_NAME_MAX, - "ldp-%d-%s", getpid (), app_name); - - if (rv >= LDP_APP_NAME_MAX) - app_name[LDP_APP_NAME_MAX - 1] = 0; + snprintf (ldp->app_name, LDP_APP_NAME_MAX, + "ldp-%d-%s", getpid (), app_name); } static inline char * -- 2.16.6