g_input_stream_read() returns -1 on error. The return value check
needs to be a signed integer comparison and thus, it has to happen
before assigning the signed return value to the unsigned local variable
This fixes an infinite loop when the operation is cancelled.
Fixes: e99f14f9 ("make sure to read the requested amount of data...")