Skip to content

Commit

Permalink
strbuf: strbuf_read_file() should return ssize_t
Browse files Browse the repository at this point in the history
It is currently declared to return int, which could overflow for
large files.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Jul 4, 2015
1 parent 351d06d commit 6c8afe4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,10 @@ int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term)
return 0;
}

int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
{
int fd, len;
int fd;
ssize_t len;

fd = open(path, O_RDONLY);
if (fd < 0)
Expand Down
2 changes: 1 addition & 1 deletion strbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint);
* Read the contents of a file, specified by its path. The third argument
* can be used to give a hint about the file size, to avoid reallocs.
*/
extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);

/**
* Read the target of a symbolic link, specified by its path. The third
Expand Down

0 comments on commit 6c8afe4

Please sign in to comment.