Coding style change
This commit is contained in:
@@ -27,7 +27,7 @@ uc_read_file(const char *f, size_t *length, size_t max)
|
||||
}
|
||||
|
||||
if ((statb.st_mode & S_IFMT) == S_IFREG) {
|
||||
if((size_t)statb.st_size > max) {
|
||||
if ((size_t)statb.st_size > max) {
|
||||
errno = EMSGSIZE;
|
||||
goto out_close;
|
||||
}
|
||||
@@ -44,21 +44,21 @@ uc_read_file(const char *f, size_t *length, size_t max)
|
||||
|
||||
p = s;
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
ssize_t rc = read(fd, p, alloc_sz - (p - s));
|
||||
if(rc == 0) {
|
||||
if (rc == 0) {
|
||||
*p = 0; // nul terminate. all malloc calls adds room for this byte
|
||||
goto out_close;
|
||||
} else if (rc == -1) {
|
||||
goto out_err_free;
|
||||
} else if(*length + rc > max) {
|
||||
} else if (*length + rc > max) {
|
||||
errno = EMSGSIZE;
|
||||
goto out_err_free;
|
||||
}
|
||||
|
||||
if(p + rc == s + alloc_sz) { //reached end of allocated memory, grow it.
|
||||
if (p + rc == s + alloc_sz) { //reached end of allocated memory, grow it.
|
||||
char *tmp = realloc(s, alloc_sz + CHUNK_SZ + 1);
|
||||
if(tmp == NULL) {
|
||||
if (tmp == NULL) {
|
||||
goto out_err_free;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user