[pacman-dev] CVS update of pacman-lib/lib/libalpm (md5driver.c server.c sha1.c)
Aaron Griffin
aaron at archlinux.org
Mon Mar 5 23:22:04 EST 2007
Date: Monday, March 5, 2007 @ 23:22:04
Author: aaron
Path: /home/cvs-pacman/pacman-lib/lib/libalpm
Modified: md5driver.c (1.7 -> 1.8) server.c (1.24 -> 1.25)
sha1.c (1.6 -> 1.7)
* Fix the double package name URL when using XferCommand
* Fixed valgrind yelling about the sprintfs in md5/sha1 routines
-------------+
md5driver.c | 6 ++++--
server.c | 12 +++++-------
sha1.c | 4 +++-
3 files changed, 12 insertions(+), 10 deletions(-)
Index: pacman-lib/lib/libalpm/md5driver.c
diff -u pacman-lib/lib/libalpm/md5driver.c:1.7 pacman-lib/lib/libalpm/md5driver.c:1.8
--- pacman-lib/lib/libalpm/md5driver.c:1.7 Mon Mar 5 17:13:34 2007
+++ pacman-lib/lib/libalpm/md5driver.c Mon Mar 5 23:22:03 2007
@@ -47,6 +47,7 @@
FILE *file;
MD_CTX context;
int len;
+ char hex[3];
unsigned char buffer[1024], digest[16];
ALPM_LOG_FUNC;
@@ -66,10 +67,11 @@
ret = calloc(33, sizeof(char));
for(i = 0; i < 16; i++) {
- sprintf(ret+(i*2), "%02x", digest[i]);
+ snprintf(hex, 3, "%02x", digest[i]);
+ strncat(ret, hex, 2);
}
- _alpm_log(PM_LOG_DEBUG, _("sha1(%s) = %s"), filename, ret);
+ _alpm_log(PM_LOG_DEBUG, _("md5(%s) = %s"), filename, ret);
return(ret);
}
return(NULL);
Index: pacman-lib/lib/libalpm/server.c
diff -u pacman-lib/lib/libalpm/server.c:1.24 pacman-lib/lib/libalpm/server.c:1.25
--- pacman-lib/lib/libalpm/server.c:1.24 Mon Mar 5 20:21:41 2007
+++ pacman-lib/lib/libalpm/server.c Mon Mar 5 23:22:03 2007
@@ -319,8 +319,10 @@
char parsedCmd[PATH_MAX] = "";
char url[PATH_MAX];
char cwd[PATH_MAX];
+
/* build the full download url */
- snprintf(url, PATH_MAX, "%s://%s%s/%s", fileurl->scheme, fileurl->host, fileurl->doc, fn);
+ snprintf(url, PATH_MAX, "%s://%s%s", fileurl->scheme, fileurl->host, fileurl->doc);
+
/* replace all occurrences of %o with fn.part */
strncpy(origCmd, handle->xfercommand, sizeof(origCmd));
ptr1 = origCmd;
@@ -328,8 +330,7 @@
usepart = 1;
ptr2[0] = '\0';
strcat(parsedCmd, ptr1);
- strcat(parsedCmd, fn);
- strcat(parsedCmd, ".part");
+ strcat(parsedCmd, output);
ptr1 = ptr2 + 2;
}
strcat(parsedCmd, ptr1);
@@ -363,10 +364,7 @@
/* download was successful */
complete = alpm_list_add(complete, fn);
if(usepart) {
- char fnpart[PATH_MAX];
- /* rename "output.part" file to "output" file */
- snprintf(fnpart, PATH_MAX, "%s.part", fn);
- rename(fnpart, fn);
+ rename(output, realfile);
}
}
chdir(cwd);
Index: pacman-lib/lib/libalpm/sha1.c
diff -u pacman-lib/lib/libalpm/sha1.c:1.6 pacman-lib/lib/libalpm/sha1.c:1.7
--- pacman-lib/lib/libalpm/sha1.c:1.6 Mon Mar 5 17:13:34 2007
+++ pacman-lib/lib/libalpm/sha1.c Mon Mar 5 23:22:03 2007
@@ -387,6 +387,7 @@
FILE *file;
struct sha_ctx context;
int len, i;
+ char hex[3];
unsigned char buffer[1024], digest[20];
char *ret;
@@ -405,7 +406,8 @@
ret = (char*)malloc(41);
ret[0] = '\0';
for(i = 0; i < 20; i++) {
- sprintf(ret+(i*2), "%02x", digest[i]);
+ snprintf(hex, 3, "%02x", digest[i]);
+ strncat(ret, hex, 2);
}
_alpm_log(PM_LOG_DEBUG, _("sha1(%s) = %s"), filename, ret);
return(ret);
More information about the pacman-dev
mailing list