]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bsdinstall/distfetch.c: check environment variables before downloading and handle...
authorrilysh <nightquick@proton.me>
Tue, 23 Apr 2024 22:40:19 +0000 (16:40 -0600)
committerWarner Losh <imp@FreeBSD.org>
Tue, 23 Apr 2024 22:42:38 +0000 (16:42 -0600)
commit91bdebc958bb0da03f604bad19f99e3b10e96ac7
tree502be6e17b4b1430f312dd46cab866c058f06ea8
parent0d4ad64077bcddcff5a170ee97273db95b9cab55
bsdinstall/distfetch.c: check environment variables before downloading and handle memory allocation errors

1. Currently, distfetch checks environment variables existence
when it will use them or in a case (in chdir()) it doesn't check
at all. As they are necessary to set before doing anything with
it, check them, if they set or not, before proceeding any further.
This also avoids extra cleaning when that environment variable
isn't set.

2. Handle memory allocation error in malloc(PATH_MAX) and replace
(sizeof const char *) with (sizeof char *). Both are similar and
const doesn't have a size.

3. Indent the error message a bit in chdir().

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1071
usr.sbin/bsdinstall/distfetch/distfetch.c