mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 03:54:59 -05:00
add real_line_size to alpm_read_buffer
We inevitably call strlen() or similar on the line returned from _alpm_archive_fgets(), so include the line size of the interesting line in the struct. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
7245bc8e8e
commit
74274b5dc3
@ -1009,7 +1009,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(eol) {
|
if(eol) {
|
||||||
size_t len = (size_t)(eol - b->block_offset);
|
size_t len = b->real_line_size = (size_t)(eol - b->block_offset);
|
||||||
memcpy(b->line_offset, b->block_offset, len);
|
memcpy(b->line_offset, b->block_offset, len);
|
||||||
b->line_offset[len] = '\0';
|
b->line_offset[len] = '\0';
|
||||||
b->block_offset = eol + 1;
|
b->block_offset = eol + 1;
|
||||||
@ -1017,7 +1017,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
|
|||||||
return ARCHIVE_OK;
|
return ARCHIVE_OK;
|
||||||
} else {
|
} else {
|
||||||
/* we've looked through the whole block but no newline, copy it */
|
/* we've looked through the whole block but no newline, copy it */
|
||||||
size_t len = (size_t)(b->block + b->block_size - b->block_offset);
|
size_t len = b->real_line_size = (size_t)(b->block + b->block_size - b->block_offset);
|
||||||
memcpy(b->line_offset, b->block_offset, len);
|
memcpy(b->line_offset, b->block_offset, len);
|
||||||
b->line_offset += len;
|
b->line_offset += len;
|
||||||
b->block_offset = b->block + b->block_size;
|
b->block_offset = b->block + b->block_size;
|
||||||
|
@ -97,6 +97,7 @@ struct archive_read_buffer {
|
|||||||
char *line_offset;
|
char *line_offset;
|
||||||
size_t line_size;
|
size_t line_size;
|
||||||
size_t max_line_size;
|
size_t max_line_size;
|
||||||
|
size_t real_line_size;
|
||||||
|
|
||||||
char *block;
|
char *block;
|
||||||
char *block_offset;
|
char *block_offset;
|
||||||
@ -108,7 +109,7 @@ struct archive_read_buffer {
|
|||||||
int _alpm_makepath(const char *path);
|
int _alpm_makepath(const char *path);
|
||||||
int _alpm_makepath_mode(const char *path, mode_t mode);
|
int _alpm_makepath_mode(const char *path, mode_t mode);
|
||||||
int _alpm_copyfile(const char *src, const char *dest);
|
int _alpm_copyfile(const char *src, const char *dest);
|
||||||
size_t _alpm_strip_newline(char *str);
|
size_t _alpm_strip_newline(char *str, size_t len);
|
||||||
|
|
||||||
int _alpm_open_archive(alpm_handle_t *handle, const char *path,
|
int _alpm_open_archive(alpm_handle_t *handle, const char *path,
|
||||||
struct stat *buf, struct archive **archive, alpm_errno_t error);
|
struct stat *buf, struct archive **archive, alpm_errno_t error);
|
||||||
|
Loading…
Reference in New Issue
Block a user