"Fossies" - the Fresh Open Source Software Archive

Member "ipfire-2.x-2.27-core174/src/patches/collectd/0020-openvpn-Make-read-functions-robust-like-in-8516f9abb.patch" (7 Apr 2023, 2361 Bytes) of package /linux/misc/ipfire-2.x-2.27-core174.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 From 46e716ee8d4208924d10f57f9ed97c99674a6ef4 Mon Sep 17 00:00:00 2001
    2 From: Michael Tremer <michael.tremer@ipfire.org>
    3 Date: Wed, 17 Sep 2014 11:31:13 +0200
    4 Subject: [PATCH 20/22] openvpn: Make read functions robust like in
    5  8516f9abb625fa7b9321e62307305aa6499be4e8
    6 
    7 ---
    8  src/openvpn.c | 21 ++++++---------------
    9  1 file changed, 6 insertions(+), 15 deletions(-)
   10 
   11 diff --git a/src/openvpn.c b/src/openvpn.c
   12 index 6a0ffbd..f686721 100644
   13 --- a/src/openvpn.c
   14 +++ b/src/openvpn.c
   15 @@ -332,7 +332,7 @@ static int multi2_read (char *name, FILE *fh)
   16     char buffer[1024];
   17     char *fields[10];
   18     const int max_fields = STATIC_ARRAY_SIZE (fields);
   19 -   int  fields_num, read = 0;
   20 +   int  fields_num;
   21     long long sum_users    = 0;
   22  
   23     while (fgets (buffer, sizeof (buffer), fh) != NULL)
   24 @@ -379,17 +379,14 @@ static int multi2_read (char *name, FILE *fh)
   25                         atoll (fields[5])); /* "Bytes Sent" */
   26             }
   27         }
   28 -
   29 -       read = 1;
   30     }
   31  
   32     if (collect_user_count)
   33     {
   34         numusers_submit(name, name, sum_users);
   35 -       read = 1;
   36     }
   37  
   38 -   return (read);
   39 +   return (1);
   40  } /* int multi2_read */
   41  
   42  /* for reading status version 3 */
   43 @@ -398,7 +395,7 @@ static int multi3_read (char *name, FILE *fh)
   44     char buffer[1024];
   45     char *fields[15];
   46     const int max_fields = STATIC_ARRAY_SIZE (fields);
   47 -   int  fields_num, read = 0;
   48 +   int  fields_num;
   49     long long sum_users    = 0;
   50  
   51     while (fgets (buffer, sizeof (buffer), fh) != NULL)
   52 @@ -447,18 +444,15 @@ static int multi3_read (char *name, FILE *fh)
   53                             atoll (fields[5])); /* "Bytes Sent" */
   54                 }
   55             }
   56 -
   57 -           read = 1;
   58         }
   59     }
   60  
   61     if (collect_user_count)
   62     {
   63         numusers_submit(name, name, sum_users);
   64 -       read = 1;
   65     }
   66  
   67 -   return (read);
   68 +   return (1);
   69  } /* int multi3_read */
   70  
   71  /* for reading status version 4 */
   72 @@ -467,7 +461,7 @@ static int multi4_read (char *name, FILE *fh)
   73     char buffer[1024];
   74     char *fields[11];
   75     const int max_fields = STATIC_ARRAY_SIZE (fields);
   76 -   int  fields_num, read = 0;
   77 +   int  fields_num;
   78     long long sum_users    = 0;
   79  
   80     while (fgets (buffer, sizeof (buffer), fh) != NULL)
   81 @@ -515,17 +509,14 @@ static int multi4_read (char *name, FILE *fh)
   82                         atoll (fields[5])); /* "Bytes Sent" */
   83             }
   84         }
   85 -
   86 -       read = 1;
   87     }
   88  
   89     if (collect_user_count)
   90     {
   91         numusers_submit(name, name, sum_users);
   92 -       read = 1;
   93     }
   94  
   95 -   return (read);
   96 +   return (1);
   97  } /* int multi4_read */
   98  
   99  /* read callback */
  100 -- 
  101 1.9.3
  102