All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/mkusers: rename variable to avoid name clashing
@ 2017-03-03 22:07 Yann E. MORIN
  2017-03-04 10:57 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2017-03-03 22:07 UTC (permalink / raw)
  To: buildroot

The LINES variable is automatically set by bash to represent the number
of lines in the terminal. That variable can be set when the shell
receives SIGWINCH.

If the shell does receive SIGWINCH after our LINES array is filled, the
content of the array is mangled.

Rename the variable to avoid that.

Fixes #9456

Reported-by: George Y. <georgebrmz@oss3d.com>
Reported-by: Paul Stewart <paulstewartis@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Arnout Vandecappelle <arnout@mind.be>
---
 support/scripts/mkusers | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/support/scripts/mkusers b/support/scripts/mkusers
index d834578..2ac76f9 100755
--- a/support/scripts/mkusers
+++ b/support/scripts/mkusers
@@ -359,7 +359,7 @@ add_one_user() {
 main() {
     local username uid group gid passwd home shell groups comment
     local line
-    local -a LINES
+    local -a ENTRIES
 
     # Some sanity checks
     if [ ${MIN_UID} -le 0 ]; then
@@ -371,7 +371,7 @@ main() {
 
     # Read in all the file in memory, exclude empty lines and comments
     while read line; do
-        LINES+=( "${line}" )
+        ENTRIES+=( "${line}" )
     done < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" )
 
     # We first create groups whose gid is not -1, and then we create groups
@@ -380,14 +380,14 @@ main() {
     # used, rather than a different automatic gid is computed.
 
     # First, create all the main groups which gid is *not* automatic
-    for line in "${LINES[@]}"; do
+    for line in "${ENTRIES[@]}"; do
         read username uid group gid passwd home shell groups comment <<<"${line}"
         [ ${gid} -ge 0 ] || continue    # Automatic gid
         add_one_group "${group}" "${gid}"
     done
 
     # Then, create all the main groups which gid *is* automatic
-    for line in "${LINES[@]}"; do
+    for line in "${ENTRIES[@]}"; do
         read username uid group gid passwd home shell groups comment <<<"${line}"
         [ ${gid} -eq -1 ] || continue    # Non-automatic gid
         add_one_group "${group}" "${gid}"
@@ -396,7 +396,7 @@ main() {
     # Then, create all the additional groups
     # If any additional group is already a main group, we should use
     # the gid of that main group; otherwise, we can use any gid
-    for line in "${LINES[@]}"; do
+    for line in "${ENTRIES[@]}"; do
         read username uid group gid passwd home shell groups comment <<<"${line}"
         if [ "${groups}" != "-" ]; then
             for g in ${groups//,/ }; do
@@ -411,7 +411,7 @@ main() {
     # uid be generated.
 
     # Now, add users whose uid is *not* automatic
-    for line in "${LINES[@]}"; do
+    for line in "${ENTRIES[@]}"; do
         read username uid group gid passwd home shell groups comment <<<"${line}"
         [ "${username}" != "-" ] || continue # Magic string to skip user creation
         [ ${uid} -ge 0         ] || continue # Automatic uid
@@ -420,7 +420,7 @@ main() {
     done
 
     # Finally, add users whose uid *is* automatic
-    for line in "${LINES[@]}"; do
+    for line in "${ENTRIES[@]}"; do
         read username uid group gid passwd home shell groups comment <<<"${line}"
         [ "${username}" != "-" ] || continue # Magic string to skip user creation
         [ ${uid} -eq -1        ] || continue # Non-automatic uid
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] support/mkusers: rename variable to avoid name clashing
  2017-03-03 22:07 [Buildroot] [PATCH] support/mkusers: rename variable to avoid name clashing Yann E. MORIN
@ 2017-03-04 10:57 ` Thomas Petazzoni
  2017-03-07 12:19   ` Peter Korsgaard
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2017-03-04 10:57 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri,  3 Mar 2017 23:07:20 +0100, Yann E. MORIN wrote:
> The LINES variable is automatically set by bash to represent the number
> of lines in the terminal. That variable can be set when the shell
> receives SIGWINCH.
> 
> If the shell does receive SIGWINCH after our LINES array is filled, the
> content of the array is mangled.
> 
> Rename the variable to avoid that.
> 
> Fixes #9456
> 
> Reported-by: George Y. <georgebrmz@oss3d.com>
> Reported-by: Paul Stewart <paulstewartis@gmail.com>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Arnout Vandecappelle <arnout@mind.be>
> ---
>  support/scripts/mkusers | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Applied to master, thanks. Peter: we want this one for the LTS branch.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] support/mkusers: rename variable to avoid name clashing
  2017-03-04 10:57 ` Thomas Petazzoni
@ 2017-03-07 12:19   ` Peter Korsgaard
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2017-03-07 12:19 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > Hello,
 > On Fri,  3 Mar 2017 23:07:20 +0100, Yann E. MORIN wrote:
 >> The LINES variable is automatically set by bash to represent the number
 >> of lines in the terminal. That variable can be set when the shell
 >> receives SIGWINCH.
 >> 
 >> If the shell does receive SIGWINCH after our LINES array is filled, the
 >> content of the array is mangled.
 >> 
 >> Rename the variable to avoid that.
 >> 
 >> Fixes #9456
 >> 
 >> Reported-by: George Y. <georgebrmz@oss3d.com>
 >> Reported-by: Paul Stewart <paulstewartis@gmail.com>
 >> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 >> Cc: Arnout Vandecappelle <arnout@mind.be>
 >> ---
 >> support/scripts/mkusers | 14 +++++++-------
 >> 1 file changed, 7 insertions(+), 7 deletions(-)

 > Applied to master, thanks. Peter: we want this one for the LTS branch.

Committed to 2017.02.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-07 12:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 22:07 [Buildroot] [PATCH] support/mkusers: rename variable to avoid name clashing Yann E. MORIN
2017-03-04 10:57 ` Thomas Petazzoni
2017-03-07 12:19   ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.