The Samba-Bugzilla – Attachment 18033 Details for
Bug 15438
CID 1539212 causes real issue when output contains only newlines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for v4-19-test
BZ15438.patch (text/plain), 7.47 KB, created by
Martin Schwenke
on 2023-08-07 23:57:14 UTC
(
hide
)
Description:
Patch for v4-19-test
Filename:
MIME Type:
Creator:
Martin Schwenke
Created:
2023-08-07 23:57:14 UTC
Size:
7.47 KB
patch
obsolete
>From 615b3f4b276f5b50b86b19203bb7612a2ba60405 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <mschwenke@ddn.com> >Date: Sun, 30 Jul 2023 11:07:47 +1000 >Subject: [PATCH 1/2] ctdb-tools: Fix CID 1539212 - signed/unsigned issue > >>>> CID 1539212: Control flow issues (NO_EFFECT) >>>> This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "p >= 0UL". >216 while (p >= 0 && output[p] == '\n') { > >This is a real problem in the unlikely event that the output contains >only newlines. > >Fix the issue by using a pointer and add a test to cover this case. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15438 > >Signed-off-by: Martin Schwenke <mschwenke@ddn.com> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit f01a179abcb33d9da6097f5ae45c7e7df1bc0397) >--- > ctdb/event/event_tool.c | 9 ++++----- > .../eventd/etc-ctdb/events/random/02.enabled.script | 8 ++++++++ > ctdb/tests/UNIT/eventd/eventd_008.sh | 10 ++++++++++ > 3 files changed, 22 insertions(+), 5 deletions(-) > >diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c >index e6d5261c217..d6b7156c69b 100644 >--- a/ctdb/event/event_tool.c >+++ b/ctdb/event/event_tool.c >@@ -203,7 +203,6 @@ static void print_status_one(struct ctdb_event_script *script) > const char *t = script->output == NULL ? "" : script->output; > size_t len = strlen(t); > char output[len+1]; >- size_t p; > char *t1, *t2; > > strlcpy(output, t, sizeof(output)); >@@ -212,10 +211,10 @@ static void print_status_one(struct ctdb_event_script *script) > * Strip trailing newlines, they are clutter and > * interfere with multi-line detection > */ >- p = len - 1; >- while (p >= 0 && output[p] == '\n') { >- output[p] = '\0'; >- p--; >+ t1 = output + len - 1; >+ while (t1 >= output && *t1 == '\n') { >+ *t1 = '\0'; >+ t1--; > } > > /* If the output is a single line then print it inline */ >diff --git a/ctdb/tests/UNIT/eventd/etc-ctdb/events/random/02.enabled.script b/ctdb/tests/UNIT/eventd/etc-ctdb/events/random/02.enabled.script >index 90df5218a9d..ace80fd8e56 100755 >--- a/ctdb/tests/UNIT/eventd/etc-ctdb/events/random/02.enabled.script >+++ b/ctdb/tests/UNIT/eventd/etc-ctdb/events/random/02.enabled.script >@@ -24,6 +24,14 @@ EOF > printf 'No trailing newline' > exit 0 > ;; >+"verbosenewlinesonly") >+ cat <<EOF >+ >+ >+ >+EOF >+ exit 0 >+ ;; > "verbosefailure") echo "args: $*"; exit 1 ;; > "verbosemultilinefailure") > cat <<EOF >diff --git a/ctdb/tests/UNIT/eventd/eventd_008.sh b/ctdb/tests/UNIT/eventd/eventd_008.sh >index c52caa0e25e..bd0fc50009c 100755 >--- a/ctdb/tests/UNIT/eventd/eventd_008.sh >+++ b/ctdb/tests/UNIT/eventd/eventd_008.sh >@@ -56,6 +56,16 @@ ok <<EOF > EOF > simple_test status random verbosemultilinenonl > >+ok_null >+simple_test run 10 random verbosenewlinesonly >+ >+ok <<EOF >+01.disabled DISABLED >+02.enabled OK DURATION DATETIME >+ OUTPUT: >+EOF >+simple_test status random verbosenewlinesonly >+ > required_result 8 <<EOF > Event verbosemultilinefailure in random failed > EOF >-- >2.39.2 > > >From e7fb931b5b1d498e9d1f33bea6d9f53fb0f1dbf0 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <mschwenke@ddn.com> >Date: Sat, 29 Jul 2023 10:07:35 +1000 >Subject: [PATCH 2/2] ctdb-doc: Fix documentation for ctdb event status > >Behaviour was changed, documentation wasn't. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15438 > >Signed-off-by: Martin Schwenke <mschwenke@ddn.com> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> > >Autobuild-User(master): Amitay Isaacs <amitay@samba.org> >Autobuild-Date(master): Mon Aug 7 09:43:33 UTC 2023 on atb-devel-224 > >(cherry picked from commit f87f02f6f99157601a6607927305e91835d45ab8) >--- > ctdb/doc/ctdb.1.xml | 58 ++++++++++++++++++++++----------------------- > 1 file changed, 29 insertions(+), 29 deletions(-) > >diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml >index 65c254762eb..2973fbf2832 100644 >--- a/ctdb/doc/ctdb.1.xml >+++ b/ctdb/doc/ctdb.1.xml >@@ -646,10 +646,10 @@ Interface[2]: Name:eth5 Link:up References:2 (active) > <para> > The output is the list of event scripts executed. > Each line shows the name, status, duration and start time >- for each script. >+ for each script. Output from each script is shown. > </para> > <para> >- Example >+ Example #1 > </para> > <screen> > # ctdb event status legacy monitor >@@ -671,6 +671,28 @@ Interface[2]: Name:eth5 Link:up References:2 (active) > 70.iscsi OK 0.009 Sat Dec 17 19:39:12 2016 > 91.lvs OK 0.007 Sat Dec 17 19:39:12 2016 > </screen> >+ >+ <para> >+ Example #2 >+ </para> >+ <screen> >+# ctdb event status legacy monitor >+00.ctdb OK 0.011 Sat Dec 17 19:40:46 2016 >+01.reclock OK 0.010 Sat Dec 17 19:40:46 2016 >+05.system OK 0.030 Sat Dec 17 19:40:46 2016 >+06.nfs OK 0.014 Sat Dec 17 19:40:46 2016 >+10.interface OK 0.041 Sat Dec 17 19:40:46 2016 >+11.natgw OK 0.008 Sat Dec 17 19:40:46 2016 >+11.routing OK 0.007 Sat Dec 17 19:40:46 2016 >+13.per_ip_routing OK 0.007 Sat Dec 17 19:40:46 2016 >+20.multipathd OK 0.007 Sat Dec 17 19:40:46 2016 >+31.clamd OK 0.007 Sat Dec 17 19:40:46 2016 >+40.vsftpd OK 0.013 Sat Dec 17 19:40:46 2016 >+41.httpd OK 0.015 Sat Dec 17 19:40:46 2016 >+49.winbind OK 0.022 Sat Dec 17 19:40:46 2016 >+50.samba ERROR 0.077 Sat Dec 17 19:40:46 2016 >+ OUTPUT: ERROR: samba tcp port 445 is not responding >+ </screen> > </listitem> > </varlistentry> > >@@ -741,37 +763,15 @@ Interface[2]: Name:eth5 Link:up References:2 (active) > <refsect2> > <title>scriptstatus</title> > <para> >- This command displays which event scripts where run in the previous >- monitoring cycle and the result of each script. If a script >- failed with an error, causing the node to become unhealthy, >- the output from that script is also shown. >+ This is an alias for <command>ctdb event status legacy >+ <optional>EVENT</optional></command>, where EVENT defaults to >+ <command>monitor</command>. > </para> > <para> > This command is deprecated. It's provided for backward >- compatibility. In place of <command>ctdb scriptstatus</command>, >- use <command>ctdb event status</command>. >+ compatibility. Use <command>ctdb event status</command> >+ instead. > </para> >- <refsect3> >- <title>Example</title> >- <screen> >-# ctdb scriptstatus >-00.ctdb OK 0.011 Sat Dec 17 19:40:46 2016 >-01.reclock OK 0.010 Sat Dec 17 19:40:46 2016 >-05.system OK 0.030 Sat Dec 17 19:40:46 2016 >-06.nfs OK 0.014 Sat Dec 17 19:40:46 2016 >-10.interface OK 0.041 Sat Dec 17 19:40:46 2016 >-11.natgw OK 0.008 Sat Dec 17 19:40:46 2016 >-11.routing OK 0.007 Sat Dec 17 19:40:46 2016 >-13.per_ip_routing OK 0.007 Sat Dec 17 19:40:46 2016 >-20.multipathd OK 0.007 Sat Dec 17 19:40:46 2016 >-31.clamd OK 0.007 Sat Dec 17 19:40:46 2016 >-40.vsftpd OK 0.013 Sat Dec 17 19:40:46 2016 >-41.httpd OK 0.015 Sat Dec 17 19:40:46 2016 >-49.winbind OK 0.022 Sat Dec 17 19:40:46 2016 >-50.samba ERROR 0.077 Sat Dec 17 19:40:46 2016 >- OUTPUT: ERROR: samba tcp port 445 is not responding >- </screen> >- </refsect3> > </refsect2> > > <refsect2> >-- >2.39.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
amitay
:
review+
Actions:
View
Attachments on
bug 15438
: 18033