On 07/08/2018 06:19 AM, Jim Meyering wrote:
> On Sat, Jul 7, 2018 at 4:13 PM, Bernhard Voelker
> <m...@bernhard-voelker.de> wrote:
>> -  static char buf[10];
>> +  static char buf[14];
> 
> Or maybe this, since you already use the intprops module, just add
> this somewhere prior: #include "intprops.h"
> 
>   static char buf[1 + INT_BUFSIZE_BOUND (info) + 1];

Even better, thanks!
I wrapped that into the attached patch in your name ... pushing soon.

Have a nice day,
Berny

>From fec33196fb5253e291ab16c005178599f575ae84 Mon Sep 17 00:00:00 2001
From: Jim Meyering <j...@meyering.net>
Date: Mon, 9 Jul 2018 14:21:33 +0200
Subject: [PATCH] maint: use gnulib's intprops module to avoid magic numbers

* find/ftsfind.c (get_fts_info_name): Use the INT_BUFSIZE_BOUND macro
to calculate the size of BUF.
---
 find/ftsfind.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/find/ftsfind.c b/find/ftsfind.c
index 57804950..39fdfbff 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -42,6 +42,7 @@
 #include "closeout.h"
 #include "error.h"
 #include "fts_.h"
+#include "intprops.h"
 #include "progname.h"
 #include "quotearg.h"
 #include "save-cwd.h"
@@ -143,7 +144,7 @@ static void init_mounted_dev_list (void);
 static const char *
 get_fts_info_name (int info)
 {
-  static char buf[14];
+  static char buf[1 + INT_BUFSIZE_BOUND (info) + 1];
   switch (info)
     {
       HANDLECASE(FTS_D);
-- 
2.18.0

Reply via email to