]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
initscripts fkt: readhash should only parse lines with a =
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sun, 16 Jun 2024 16:02:42 +0000 (18:02 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Aug 2024 12:19:56 +0000 (12:19 +0000)
A line without a = is clearly invalid.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/functions
tests/src/initscripts/system/functions/data/2
tests/src/initscripts/system/functions/data/2_output_stderr

index 34da7c38ac574e2404c158870e23d6142535b2b9..84aaf251ada55e8f52216bce5561f323c426f7ac 100644 (file)
@@ -910,6 +910,12 @@ readhash() {
                        continue
                fi
 
+               # Skip lines without a =
+               if ! [[ ${line} =~ [^=]*=[^=]*$ ]]; then
+                       echo "Invalid line '${line}'" >&2
+                       continue
+               fi
+
                local key="${line%=*}"
                local val="${line#*=}"
 
index 3060ad880e52ae7e20f7ce2dd5a8c75253109ea1..760294c30f396f6ac3b36671ae269988e094adaa 100644 (file)
@@ -15,6 +15,7 @@ RED_ADDRESS=0.0.0.0
 RED_NETMASK=0.0.0.0
 RED_TYPE=PPPOE
 RED_NETADDRESS=0.0.0.0
+Line_without_a_equal_sign_is_also_invalid
 
 # Comment for testing  
     # Comment for testing Comments with spaces before
index f29e94b19129dd9531686b9fb5abb7f102bdc27f..82f035e26da282dd4ba61dcf7073714ae39e093b 100644 (file)
@@ -6,3 +6,4 @@ Invalid key '-RED_DEV'
 Invalid key 'RE??D_MACADDR'
 Invalid key 'RED&&_DRIVER'
 Invalid key '0BLUE_DEV'
+Invalid line 'Line_without_a_equal_sign_is_also_invalid'