tar_block_read() function can return negative integer and it should be
handled properly. In the previous code, only '-1' and '0' cases are
handled but no negative values less than '-1'.
To fix this issue, negative values less than '-1' is also handled.
Change-Id: Ib3fd0478b008cbe298694ccc10ddf66cfbb7604e
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
while (size > 0) {
char buf[T_BLOCKSIZE];
int r_read = tar_block_read(tar, buf);
- switch (r_read) {
- case -1:
+
+ if (r_read < 0) {
fprintf(stderr, "Couldn't read from the archive (errno: %m)\n");
return -1;
- case 0:
+ }
+
+ if (r_read == 0) {
fprintf(stderr, "We have reached EOF unexpectedly\n");
return -1;
}
}
int r_read = tar_block_read(data->patch_tar, data->buff_in);
- switch (r_read) {
- case -1:
+
+ if (r_read < 0) {
fprintf(stderr, "Couldn't read from the archive (errno: %m)\n");
return PF_ERROR_DECOMPRESSION;
- case 0:
+ }
+
+ if (r_read == 0) {
fprintf(stderr, "We have reached EOF unexpectedly\n");
return PF_ERROR_DECOMPRESSION;
}
- assert(r_read >= 0);
-
if ((size_t)r_read > data->patch_remaining) {
r_read = data->patch_remaining;
}