File sv-bug-48030-find-exec-plus-does-not-pass-all-arguments.patch of Package findutils

Upstream patch, to be removed with findutils-4.7.0

http://git.sv.gnu.org/cgit/findutils.git/commit/?id=8cdc9767e3

Differences to upstream patch:
- Fix conflict in NEWS.
- Strip down to the core change, i.e., remove test.

Manual test (or trigger the bug with the unpatched version):

  #-test case start-
  #!/bin/bash
  #cd $HOME
  mkdir RashuBug RashuBug-bin
  seq -f "RashuBug/abcdefghijklmnopqrstuv%04g" 901 | xargs touch
  seq -f "RashuBug/abcdefghijklmnopqrstu%04g" 902 3719 | xargs touch

  # Number of files we have created in directory:
  ls RashuBug/* | wc -l
  #output: 3719

  ## Now create an echo command which is 6 characters long
  ln -s `which echo` RashuBug-bin/echo56
  PATH="$PWD/RashuBug-bin:$PATH"

  ## See the difference in the output of the following commands.

  # Correct: -exec \;
  find RashuBug -type f -exec echo56 '{}' \; | tr ' ' '\n' | wc -l
  #output: 3719

  # Correct: -exec echo +
  find RashuBug -type f -exec echo   '{}' + | tr ' ' '\n' | wc -l
  #output: 3719

  # The last file is missing with the buggy find(1).
  find RashuBug -type f -exec echo56 '{}' + | tr ' ' '\n' | wc -l
  #buggy output: 3718
  #expected: 3719

  #rm -rf RashuBug RashuBug-bin
  #-test case end-

----------------------------------------------------------------------
From d15e640fc76f8b931549f79f2edc86d5e552e8bf Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Tue, 31 May 2016 00:31:50 +0200
Subject: [PATCH] Fix bug #48030: find: -exec + does not pass all arguments in
 certain cases

When the -exec arguments buffer (usually 128k) is full and the given
command has been executed with all that arguments, find(1) missed to
execute the command yet another time if only 1 another file would have
to be processed.
Both find(1), i.e., nowadays FTS-version, and oldfind are affected.
This bug was present since the implementation of '-exec +' in 2005,
see commit FINDUTILS_4_2_11-1-25-gf0a6ac6.

* lib/buildcmd.c (bc_push_arg): Move the assignment to set 'state->todo'
to 1 down after the immediate execution which resets that flag.
* NEWS (Bug Fixes): Mention the fix.

Reported by Joe Philip Ninan <indiajoe@gmail.com> in
https://savannah.gnu.org/bugs/?48030
---
 NEWS           |   12 ++++++++++++
 lib/buildcmd.c |   10 +++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
 create mode 100755 find/testsuite/sv-48030-exec-plus-bug.sh

Index: NEWS
===================================================================
--- NEWS.orig
+++ NEWS
@@ -1,5 +1,17 @@
 GNU findutils NEWS - User visible changes.      -*- outline -*- (allout)
 
+* openSUSE downstream changes
+
+** Bug Fixes
+
+Savannah bug
+#48030: find -exec + does not pass all arguments for certain specific filename
+        lengths.  After the internal (usually 128k) buffer is full and find(1)
+        executed the given command with these arguments, it would miss to run
+        the command yet another time if only one other file argument has to be
+        processed.  Bug introduced in FINDUTILS-4.2.12.
+
+
 * Major changes in release 4.5.12, 2013-09-22
 
 ** Functional Changes to find
Index: lib/buildcmd.c
===================================================================
--- lib/buildcmd.c.orig
+++ lib/buildcmd.c
@@ -357,11 +357,6 @@ bc_push_arg (struct buildcmd_control *ct
 
   assert (arg != NULL);
 
-  if (!initial_args)
-    {
-      state->todo = 1;
-    }
-
   if (!terminate)
     {
       if (state->cmd_argv_chars + len + pfxlen > ctl->arg_max)
@@ -381,6 +376,11 @@ bc_push_arg (struct buildcmd_control *ct
             bc_do_exec (ctl, state);
     }
 
+  if (!initial_args)
+    {
+      state->todo = 1;
+    }
+
   if (state->cmd_argc >= state->cmd_argv_alloc)
     {
       /* XXX: we could use extendbuf() here. */