NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/52902: dm: Avoid junk at the end of each line in dmsetup(8) output



>Number:         52902
>Category:       kern
>Synopsis:       dm: Avoid junk at the end of each line in dmsetup(8) output
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 05 14:00:00 +0000 2018
>Originator:     Tomohiro Kusumi
>Release:        -current, but existed since before
>Organization:
>Environment:
Architecture independent.
# uname -r
8.99.9

>Description:
Although having never looked at details of prop_dictionary_util(3)
source, it seems "prop_dictionary_t target_dict" must not be left
without being initialized with C string even if it's a blank string
possibly after prop_dictionary_set_int32(). Otherwise one will see
a junk byte at the end of each line in dmsetup(8) status output.

>How-To-Repeat:
See below dmsetup example using a meaningless dm-linear mapping,
just to showcase irrelevant junk bytes.

 # cat ./table.txt
 0 1000 linear /dev/sd1a 0
 1000 2000 linear /dev/sd1a 1000
 2000 3000 linear /dev/sd1a 2000
 3000 4000 linear /dev/sd1a 3000
 4000 5000 linear /dev/sd1a 4000
 # dmsetup create linear1 ./table.txt
 create and load called
 # dmsetup status /dev/mapper/linear1 > dmsetup_status.out

The screenshot below shows dmsetup_status.out file has an irrelevant
binary appended at the end of each line.
https://leaf.dragonflybsd.org/~tkusumi/diff/netbsd/dm_setup_eol_junk.PNG

The first od output below shows there is something before LF, while
the second one with this fix applied has no such bytes appended.

 # od -tx1z -Ax ./dmsetup_status.out
 000000 30 20 31 30 30 30 20 6c 69 6e 65 61 72 20 03 0a  >0 1000 linear ..<
 000010 31 30 30 30 20 32 30 30 30 20 6c 69 6e 65 61 72  >1000 2000 linear<
 000020 20 07 0a 32 30 30 30 20 33 30 30 30 20 6c 69 6e  > ..2000 3000 lin<
 000030 65 61 72 20 0b 0a 33 30 30 30 20 34 30 30 30 20  >ear ..3000 4000 <
 000040 6c 69 6e 65 61 72 20 0f 0a 34 30 30 30 20 35 30  >linear ..4000 50<
 000050 30 30 20 6c 69 6e 65 61 72 20 0a                 >00 linear .<
 00005b
 # od -tx1z -Ax ./dmsetup_status_fixed.out
 000000 30 20 31 30 30 30 20 6c 69 6e 65 61 72 20 0a 31  >0 1000 linear .1<
 000010 30 30 30 20 32 30 30 30 20 6c 69 6e 65 61 72 20  >000 2000 linear <
 000020 0a 32 30 30 30 20 33 30 30 30 20 6c 69 6e 65 61  >.2000 3000 linea<
 000030 72 20 0a 33 30 30 30 20 34 30 30 30 20 6c 69 6e  >r .3000 4000 lin<
 000040 65 61 72 20 0a 34 30 30 30 20 35 30 30 30 20 6c  >ear .4000 5000 l<
 000050 69 6e 65 61 72 20 0a                             >inear .<
 000057

>Fix:
https://leaf.dragonflybsd.org/~tkusumi/diff/netbsd/dm-3.patch



Home | Main Index | Thread Index | Old Index