lib/conflict: save strlen call by reusing snprintf return
The return should probably be checked to ensure its not longer than PATH_MAX, but I have no idea what the correct behavior is when that happens. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
3d4656c020
commit
8c8f043717
|
@ -465,8 +465,9 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
|||
int resolved_conflict = 0;
|
||||
struct stat lsbuf;
|
||||
char path[PATH_MAX];
|
||||
size_t pathlen;
|
||||
|
||||
snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
|
||||
pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
|
||||
|
||||
/* stat the file - if it exists, do some checks */
|
||||
if(_alpm_lstat(path, &lsbuf) != 0) {
|
||||
|
@ -490,7 +491,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
|||
/* if we made it to here, we want all subsequent path comparisons to
|
||||
* not include the trailing slash. This allows things like file ->
|
||||
* directory replacements. */
|
||||
path[strlen(path) - 1] = '\0';
|
||||
path[pathlen - 1] = '\0';
|
||||
}
|
||||
|
||||
relative_path = path + strlen(handle->root);
|
||||
|
|
Loading…
Reference in New Issue