0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

librb: gnutls: check return value of fread()

This commit is contained in:
Simon Arlott 2016-04-26 20:28:12 +01:00
parent 7380ded584
commit 31646e89ba
No known key found for this signature in database
GPG key ID: C8975F2043CA5D24

View file

@ -335,6 +335,7 @@ rb_load_file_into_datum_t(const char *file)
FILE *f;
gnutls_datum_t *datum;
struct stat fileinfo;
int count;
if((f = fopen(file, "r")) == NULL)
return NULL;
if(fstat(fileno(f), &fileinfo))
@ -348,8 +349,14 @@ rb_load_file_into_datum_t(const char *file)
datum->size = fileinfo.st_size;
datum->data = rb_malloc(datum->size + 1);
fread(datum->data, datum->size, 1, f);
count = fread(datum->data, datum->size, 1, f);
fclose(f);
if(count != 1)
{
rb_free_datum_t(datum);
return NULL;
}
return datum;
}