defaults read deletes entire file when reading invalid plist
Originator: | eholtam | ||
Number: | rdar://37729361 | Date Originated: | 20-Feb-2018 08:44 PM |
Status: | Open | Resolved: | |
Product: | macOS + SDK | Product Version: | 10.13.3 |
Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: If a plist is invalid (missing a closing tag for example) attempting to read the plist with `defaults read /path/to/plist` deletes the entire file. Steps to Reproduce: 1) Create a plist `defaults write /Users/Shared/test test -string test 2) Convert the plist to xml `plutil -convert xml1 /Users/Shared/test.plist` 3) Edit the plist to remove a closing tag 4) Attempt to read the plist `defaults read /Users/Shared/test` Expected Results: Error that the file could not be read Actual Results: File is deleted Version: 10.13.3 Notes: eholtam:Desktop eholtam$ ls -l test.plist -rw-------@ 1 eholtam domain\Domain Users 219 Feb 20 20:37 test.plist eholtam:Desktop eholtam$ cat test.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>test</key> <string>test </dict> </plist> eholtam:Desktop eholtam$ defaults read /Users/eholtam/Desktop/test 2018-02-20 20:37:59.188 defaults[7734:40969] Domain /Users/eholtam/Desktop/test does not exist eholtam:Desktop eholtam$ ls -l test.plist ls: test.plist: No such file or directory
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!