Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Remove the ability to generate MD5 sums it is not needed anymore
Baptiste Daroussin committed 11 years ago
commit fd3b7a10ec3f0795e93b21914f92cf9cf7a04baf
parent a177614
4 files changed +3 -46
modified libpkg/pkg_create.c
@@ -93,13 +93,8 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
		}
		else {
			if (file->sum[0] == '\0') {
-
				if (pkg->type == PKG_OLD_FILE) {
-
					if (md5_file(fpath, sha256) != EPKG_OK)
-
						return (EPKG_FATAL);
-
				} else {
-
					if (sha256_file(fpath, sha256) != EPKG_OK)
-
						return (EPKG_FATAL);
-
				}
+
				if (sha256_file(fpath, sha256) != EPKG_OK)
+
					return (EPKG_FATAL);
				strlcpy(file->sum, sha256, sizeof(file->sum));
			}
		}
modified libpkg/pkg_ports.c
@@ -360,10 +360,7 @@ meta_file(struct plist *p, char *line, struct file_attr *a, bool is_config)

		if (regular) {
			p->flatsize += st.st_size;
-
			if (pkg_type(p->pkg) == PKG_OLD_FILE)
-
				md5_file(testpath, sha256);
-
			else
-
				sha256_file(testpath, sha256);
+
			sha256_file(testpath, sha256);
			buf = sha256;
			if (is_config) {
				size_t sz;
modified libpkg/private/utils.h
@@ -100,7 +100,6 @@ void sha256_buf_bin(const char *, size_t len, char[SHA256_DIGEST_LENGTH]);
int sha256_file(const char *, char[SHA256_DIGEST_LENGTH * 2 +1]);
int sha256_fileat(int fd, const char *, char[SHA256_DIGEST_LENGTH * 2 +1]);
int sha256_fd(int fd, char[SHA256_DIGEST_LENGTH * 2 +1]);
-
int md5_file(const char *, char[MD5_DIGEST_LENGTH * 2 +1]);

int rsa_new(struct rsa_key **, pem_password_cb *, char *path);
void rsa_free(struct rsa_key *);
modified libpkg/utils.c
@@ -376,40 +376,6 @@ md5_hash(unsigned char hash[MD5_DIGEST_LENGTH],
	out[MD5_DIGEST_LENGTH * 2] = '\0';
}

-
int
-
md5_file(const char *path, char out[MD5_DIGEST_LENGTH * 2 + 1])
-
{
-
	FILE *fp;
-
	char buffer[BUFSIZ];
-
	unsigned char hash[SHA256_DIGEST_LENGTH];
-
	size_t r = 0;
-
	MD5_CTX md5;
-

-
	if ((fp = fopen(path, "rb")) == NULL) {
-
		pkg_emit_errno("fopen", path);
-
		return EPKG_FATAL;
-
	}
-

-
	MD5_Init(&md5);
-

-
	while ((r = fread(buffer, 1, BUFSIZ, fp)) > 0)
-
		MD5_Update(&md5, buffer, r);
-

-
	if (ferror(fp) != 0) {
-
		fclose(fp);
-
		out[0] = '\0';
-
		pkg_emit_errno("fread", path);
-
		return EPKG_FATAL;
-
	}
-

-
	fclose(fp);
-

-
	MD5_Final(hash, &md5);
-
	md5_hash(hash, out);
-

-
	return (EPKG_OK);
-
}
-

static void
sha256_hash(unsigned char hash[SHA256_DIGEST_LENGTH],
    char out[SHA256_DIGEST_LENGTH * 2 + 1])