debug_return_int(-1);
}
if (ofd != -1) {
- while ((nread = read(ofd, buf, sizeof(buf))) != 0) {
+ while ((nread = read(ofd, buf, sizeof(buf))) > 0) {
if ((nwritten = write(tfd, buf, nread)) != nread) {
if (nwritten == -1)
sudo_warn("%s", tf[j].tfile);
else
sudo_warnx(U_("%s: short write"), tf[j].tfile);
- close(ofd);
- close(tfd);
- debug_return_int(-1);
+ break;
}
}
+ if (nread != 0) {
+ if (nread < 0)
+ sudo_warn("%s", files[i]);
+ close(ofd);
+ close(tfd);
+ debug_return_int(-1);
+ }
close(ofd);
}
/*