mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
* Fix the double package name URL when using XferCommand
* Fixed valgrind yelling about the sprintfs in md5/sha1 routines
This commit is contained in:
parent
5baba84397
commit
90b75a0435
@ -47,6 +47,7 @@ char* _alpm_MDFile(char *filename)
|
|||||||
FILE *file;
|
FILE *file;
|
||||||
MD_CTX context;
|
MD_CTX context;
|
||||||
int len;
|
int len;
|
||||||
|
char hex[3];
|
||||||
unsigned char buffer[1024], digest[16];
|
unsigned char buffer[1024], digest[16];
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
@ -66,10 +67,11 @@ char* _alpm_MDFile(char *filename)
|
|||||||
|
|
||||||
ret = calloc(33, sizeof(char));
|
ret = calloc(33, sizeof(char));
|
||||||
for(i = 0; i < 16; i++) {
|
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(ret);
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -319,8 +319,10 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
|
|||||||
char parsedCmd[PATH_MAX] = "";
|
char parsedCmd[PATH_MAX] = "";
|
||||||
char url[PATH_MAX];
|
char url[PATH_MAX];
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
|
|
||||||
/* build the full download url */
|
/* 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 */
|
/* replace all occurrences of %o with fn.part */
|
||||||
strncpy(origCmd, handle->xfercommand, sizeof(origCmd));
|
strncpy(origCmd, handle->xfercommand, sizeof(origCmd));
|
||||||
ptr1 = origCmd;
|
ptr1 = origCmd;
|
||||||
@ -328,8 +330,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
|
|||||||
usepart = 1;
|
usepart = 1;
|
||||||
ptr2[0] = '\0';
|
ptr2[0] = '\0';
|
||||||
strcat(parsedCmd, ptr1);
|
strcat(parsedCmd, ptr1);
|
||||||
strcat(parsedCmd, fn);
|
strcat(parsedCmd, output);
|
||||||
strcat(parsedCmd, ".part");
|
|
||||||
ptr1 = ptr2 + 2;
|
ptr1 = ptr2 + 2;
|
||||||
}
|
}
|
||||||
strcat(parsedCmd, ptr1);
|
strcat(parsedCmd, ptr1);
|
||||||
@ -363,10 +364,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
|
|||||||
/* download was successful */
|
/* download was successful */
|
||||||
complete = alpm_list_add(complete, fn);
|
complete = alpm_list_add(complete, fn);
|
||||||
if(usepart) {
|
if(usepart) {
|
||||||
char fnpart[PATH_MAX];
|
rename(output, realfile);
|
||||||
/* rename "output.part" file to "output" file */
|
|
||||||
snprintf(fnpart, PATH_MAX, "%s.part", fn);
|
|
||||||
rename(fnpart, fn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chdir(cwd);
|
chdir(cwd);
|
||||||
|
@ -387,6 +387,7 @@ char* _alpm_SHAFile(char *filename) {
|
|||||||
FILE *file;
|
FILE *file;
|
||||||
struct sha_ctx context;
|
struct sha_ctx context;
|
||||||
int len, i;
|
int len, i;
|
||||||
|
char hex[3];
|
||||||
unsigned char buffer[1024], digest[20];
|
unsigned char buffer[1024], digest[20];
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
@ -405,7 +406,8 @@ char* _alpm_SHAFile(char *filename) {
|
|||||||
ret = (char*)malloc(41);
|
ret = (char*)malloc(41);
|
||||||
ret[0] = '\0';
|
ret[0] = '\0';
|
||||||
for(i = 0; i < 20; i++) {
|
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);
|
_alpm_log(PM_LOG_DEBUG, _("sha1(%s) = %s"), filename, ret);
|
||||||
return(ret);
|
return(ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user