diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/add.c | 23 | ||||
-rw-r--r-- | lib/libalpm/backup.c | 2 | ||||
-rw-r--r-- | lib/libalpm/conflict.c | 2 | ||||
-rw-r--r-- | lib/libalpm/dload.c | 2 |
4 files changed, 14 insertions, 15 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index b8b1ca18..2d4b7baa 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -257,6 +257,8 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, /* check newpkg first, so that adding backup files is retroactive */ backup = _alpm_needbackup(entryname, alpm_pkg_get_backup(newpkg)); if(backup) { + /* if we force hash_orig to be non-NULL retroactive backup works */ + hash_orig = ""; needbackup = 1; } @@ -268,11 +270,6 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, needbackup = 1; } } - - /* if we force hash_orig to be non-NULL retroactive backup works */ - if(needbackup && !hash_orig) { - hash_orig = ""; - } } } /* else if(S_ISLNK(entrymode)) */ @@ -319,7 +316,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, _alpm_log(handle, PM_LOG_DEBUG, "original: %s\n", hash_orig); if(!oldpkg) { - if(strcmp(hash_local, hash_pkg) != 0) { + if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) != 0) { /* looks like we have a local file that has a different hash as the * file in the package, move it to a .pacorig */ char newpath[PATH_MAX]; @@ -352,9 +349,9 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, } else if(hash_orig) { /* the fun part */ - if(strcmp(hash_orig, hash_local) == 0) { + if(hash_local && strcmp(hash_orig, hash_local) == 0) { /* installed file has NOT been changed by user */ - if(strcmp(hash_orig, hash_pkg) != 0) { + if(hash_pkg && strcmp(hash_orig, hash_pkg) != 0) { _alpm_log(handle, PM_LOG_DEBUG, "action: installing new file: %s\n", entryname_orig); @@ -366,18 +363,18 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, errors++; } } else { - /* there's no sense in installing the same file twice, install - * ONLY is the original and package hashes differ */ + /* no sense in installing the same file twice, install + * ONLY if the original and package hashes differ */ _alpm_log(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n"); unlink(checkfile); } - } else if(strcmp(hash_orig, hash_pkg) == 0) { + } else if(hash_pkg && strcmp(hash_orig, hash_pkg) == 0) { /* originally installed file and new file are the same - this * implies the case above failed - i.e. the file was changed by a * user */ _alpm_log(handle, PM_LOG_DEBUG, "action: leaving existing file in place\n"); unlink(checkfile); - } else if(strcmp(hash_local, hash_pkg) == 0) { + } else if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) == 0) { /* this would be magical. The above two cases failed, but the * user changes just so happened to make the new file exactly the * same as the one in the package... skip it */ @@ -460,6 +457,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg, alpm_db_t *db = handle->db_local; alpm_trans_t *trans = handle->trans; + ASSERT(trans != NULL, return -1); + snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", _alpm_db_path(db), alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg)); diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index 0334042c..becc7be9 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -40,7 +40,7 @@ int _alpm_split_backup(const char *string, alpm_backup_t **backup) STRDUP(str, string, return -1); /* tab delimiter */ - ptr = strchr(str, '\t'); + ptr = str ? strchr(str, '\t') : NULL; if(ptr == NULL) { (*backup)->name = str; (*backup)->hash = NULL; diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index e54c7147..5d9bbf23 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -65,7 +65,7 @@ void _alpm_conflict_free(alpm_conflict_t *conflict) alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict) { alpm_conflict_t *newconflict; - CALLOC(newconflict, 1, sizeof(alpm_conflict_t), ); + CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL); STRDUP(newconflict->package1, conflict->package1, return NULL); STRDUP(newconflict->package2, conflict->package2, return NULL); diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 73f75144..fd83aac0 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -162,7 +162,7 @@ static int curl_download_internal(alpm_handle_t *handle, char hostname[256]; char error_buffer[CURL_ERROR_SIZE]; struct stat st; - long timecond, remote_time; + long timecond, remote_time = -1; double remote_size, bytes_dl; struct sigaction sig_pipe[2], sig_int[2]; struct fileinfo dlfile; |