initrd driver now properly handles a request to read more data than available

This commit is contained in:
pjht 2020-08-23 17:34:24 -05:00
parent ff2dbb91e1
commit edfb52936d

View File

@ -19,13 +19,7 @@ void read(void* args) {
rpc_deallocate_buf(args,state.sizeorpos); rpc_deallocate_buf(args,state.sizeorpos);
long max_data=initrd_size-pos; long max_data=initrd_size-pos;
if (size>max_data) { if (size>max_data) {
serial_print("Reading too much data from initrd\n"); size=max_data;
state.buf=NULL;
state.sizeorpos=0;
serialize_int(0,&state);
rpc_return(state.buf,state.sizeorpos);
free(state.buf);
pthread_exit(NULL);
} }
char* data=malloc(sizeof(char)*size); char* data=malloc(sizeof(char)*size);
for (long i=0;i<size;i++) { for (long i=0;i<size;i++) {