X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libopkg%2Ffile_util.c;h=897546e838d4d8298ddb94a2546fdbfb283371fb;hb=a91236f83d1777cf9dd94c709f0a974b173c7b8b;hp=964473a51b60183fe38cdc856f69f899cd379745;hpb=599cc259280ccde97b2a3b459c3f015db6390127;p=oweals%2Fopkg-lede.git diff --git a/libopkg/file_util.c b/libopkg/file_util.c index 964473a..897546e 100644 --- a/libopkg/file_util.c +++ b/libopkg/file_util.c @@ -16,6 +16,8 @@ General Public License for more details. */ +#include "config.h" + #include #include #include @@ -173,9 +175,9 @@ char *file_md5sum_alloc(const char *file_name) md5sum_hex[i*2] = bin2hex[md5sum_bin[i] >> 4]; md5sum_hex[i*2+1] = bin2hex[md5sum_bin[i] & 0xf]; } - + md5sum_hex[md5sum_hex_len] = '\0'; - + return md5sum_hex; } @@ -220,9 +222,9 @@ char *file_sha256sum_alloc(const char *file_name) sha256sum_hex[i*2] = bin2hex[sha256sum_bin[i] >> 4]; sha256sum_hex[i*2+1] = bin2hex[sha256sum_bin[i] & 0xf]; } - + sha256sum_hex[sha256sum_hex_len] = '\0'; - + return sha256sum_hex; } @@ -236,6 +238,11 @@ rm_r(const char *path) DIR *dir; struct dirent *dent; + if (path == NULL) { + opkg_perror(ERROR, "Missing directory parameter"); + return -1; + } + dir = opendir(path); if (dir == NULL) { opkg_perror(ERROR, "Failed to open dir %s", path);