[openSUSE/osc] 674ea7: Avoid a potential TypeError in util.ArFile.saveTo
![](https://seccdn.libravatar.org/avatar/9181eb84f9c35729a3bad740fb7f9d93.jpg?s=120&d=mm&r=g)
Branch: refs/heads/master Home: https://github.com/openSUSE/osc Commit: 674ea78815d8df4750b8c5c3b6d889ce9b1f3247 https://github.com/openSUSE/osc/commit/674ea78815d8df4750b8c5c3b6d889ce9b1f3... Author: Marcus Huewe <suse-tux@gmx.de> Date: 2020-11-22 (Sun, 22 Nov 2020) Changed paths: M osc/util/ar.py Log Message: ----------- Avoid a potential TypeError in util.ArFile.saveTo If no dir is passed to util.ArFile.saveTo, dir is set to os.getcwd(), which returns a str. Since self.name is a bytes, the subsequent os.path.join(dir, self.name) results in a TypeError. To fix this, use os.getcwdb(), which returns a bytes instead of a str. Commit: 1933da5bccd27844c8893c5d45ff252be60dc3c2 https://github.com/openSUSE/osc/commit/1933da5bccd27844c8893c5d45ff252be60dc... Author: Marcus Huewe <suse-tux@gmx.de> Date: 2020-11-22 (Sun, 22 Nov 2020) Changed paths: M osc/util/cpio.py Log Message: ----------- Use os.getcwdb() instead of os.getcwd().encode() in util.cpio.CpioRead Using os.getcwd() in combination with a subsequent .encode() is error prone: marcus@linux:~> mkdir illegal_utf-8_encoding_$'\xff'_dir marcus@linux:~> cd illegal_utf-8_encoding_$'\xff'_dir/ marcus@linux:~/illegal_utf-8_encoding_ÿ_dir> python3 Python 3.8.6 (default, Nov 09 2020, 12:09:06) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information.
import os os.getcwd().encode() Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 36: surrogates not allowed
Hence, use os.getcwdb(), which returns a bytes, instead of os.getcwd().encode(). Fixes: commit 36f7b8ffe91ff759c938b1afce5f83be57b39671 ("Fix a potential TypeError in CpioRead.copyin and CpioRead.copyin_file") Commit: 5428c09cd7d77c4d96a740268641eccdcb938a0e https://github.com/openSUSE/osc/commit/5428c09cd7d77c4d96a740268641eccdcb938... Author: Marcus Huewe <suse-tux@gmx.de> Date: 2020-12-01 (Tue, 01 Dec 2020) Changed paths: M osc/util/ar.py M osc/util/cpio.py Log Message: ----------- Merge branch 'use_getcwdb' of https://github.com/marcus-h/osc os.getcwd() fixes: - Fix a potential TypeERror in util.ArFile.saveTo. - Avoid error prone use of os.getcwd().encode() in util.cpio.CpioRead. Compare: https://github.com/openSUSE/osc/compare/926c2eb4223f...5428c09cd7d7
participants (1)
-
Marcus Hüwe