aboutsummaryrefslogtreecommitdiff
path: root/flx/fct1.c
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2006-07-16 14:53:23 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 11:51:23 +0200
commitf179c4f810adddd808eddf0312cdb08673824ac2 (patch)
treef96b4c5521a74a06a41e07a2c1624402e555e337 /flx/fct1.c
parent[RELEASE] flxutils-0.1.11.3 (diff)
downloadflxutils-f179c4f810adddd808eddf0312cdb08673824ac2.tar.xz
[RELEASE] flxutils-0.1.12v0.1.12
Diffstat (limited to 'flx/fct1.c')
-rw-r--r--flx/fct1.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/flx/fct1.c b/flx/fct1.c
index 79378a3..811391a 100644
--- a/flx/fct1.c
+++ b/flx/fct1.c
@@ -224,8 +224,8 @@ int browse_over_path(char *path, PROTO_FS(*fct), void *data) {
/* build an MD5 checksum from data in file */
char *checksum_md5_from_file(char *file) {
int fd;
- size_t size;
- char *checksum_md5 = 0, blk[BUFFER_LENGTH];
+ ssize_t size;
+ char *checksum_md5 = NULL, blk[BUFFER_LENGTH];
MD5_CTX md5_ctx;
if ((fd = open(file, O_RDONLY)) < 0 ) {
@@ -236,8 +236,11 @@ char *checksum_md5_from_file(char *file) {
while ((size = read(fd, blk, BUFFER_LENGTH)) > 0)
MD5_Update(&md5_ctx, blk, size);
close(fd);
- checksum_md5 = MALLOC(16);
- MD5_Final(checksum_md5, &md5_ctx);
+ // if size = -1, there is a read error, don't do anything
+ if (size == 0) { // last read is null
+ checksum_md5 = MALLOC(16);
+ MD5_Final(checksum_md5, &md5_ctx);
+ }
}
return (checksum_md5);
}