From cdb46ef3fa6d2bea95ae45b8b807497982b18fd5 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sun, 4 Mar 2007 09:08:54 +0000 Subject: * Fixed a whole mess of extra '/' pathing issues when a different root is specified * Use db->path when appropriate * Commented out the FAKEROOT checks in libalpm. This should never ever be done. TODO test this quite a bit, as this will never cause the transactions to fail if RW operations are requested... right now it is totally up to the front end to decide when to fail * Use realpath() to canonicalize the root path when specified, so _alpm_makepath() doesn't freak out * Fixed some output/indent of MDFile and SHAFile algorithms * More efficient sprintf() usage in MDFile/SHAFile * Added real error output to _alpm_makepath --- lib/libalpm/sha1.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'lib/libalpm/sha1.c') diff --git a/lib/libalpm/sha1.c b/lib/libalpm/sha1.c index cf1831ea..956e87a9 100644 --- a/lib/libalpm/sha1.c +++ b/lib/libalpm/sha1.c @@ -386,35 +386,34 @@ documentation and/or software. char* _alpm_SHAFile(char *filename) { - FILE *file; - struct sha_ctx context; - int len, i; - unsigned char buffer[1024], digest[20]; - char *ret; - - ALPM_LOG_FUNC; - - if((file = fopen(filename, "rb")) == NULL) { - fprintf(stderr, _("%s can't be opened\n"), filename); - } else { - sha_init_ctx(&context); - while((len = fread(buffer, 1, 1024, file))) { - sha_process_bytes(buffer, len, &context); + FILE *file; + struct sha_ctx context; + int len, i; + unsigned char buffer[1024], digest[20]; + char *ret; + + ALPM_LOG_FUNC; + + if((file = fopen(filename, "rb")) == NULL) { + _alpm_log(PM_LOG_ERROR, _("sha1: %s can't be opened\n"), filename); + } else { + sha_init_ctx(&context); + while((len = fread(buffer, 1, 1024, file))) { + sha_process_bytes(buffer, len, &context); + } + sha_finish_ctx(&context, digest); + fclose(file); + + ret = (char*)malloc(41); + ret[0] = '\0'; + for(i = 0; i < 20; i++) { + sprintf(ret+(i*2), "%02x", digest[i]); + } + _alpm_log(PM_LOG_DEBUG, _("sha1(%s) = %s"), filename, ret); + return(ret); } - sha_finish_ctx(&context, digest); - fclose(file); -#ifdef DEBUG - SHAPrint(digest); -#endif - ret = (char*)malloc(41); - ret[0] = '\0'; - for(i = 0; i < 20; i++) { - sprintf(ret, "%s%02x", ret, digest[i]); - } - return(ret); - } - return(NULL); + return(NULL); } /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3-54-g00ecf