Skip to content

Commit

Permalink
Exit with (eventual) error if any characters failed to convert withou…
Browse files Browse the repository at this point in the history
…t -c.
  • Loading branch information
landley committed Dec 15, 2023
1 parent d908031 commit 53d8a67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions toys/posix/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ static void do_iconv(int fd, char *name)
iconv(TT.ic, &in, &inlen, &out, &outlen);
if (in == toybuf) {
// Skip first byte of illegal sequence to avoid endless loops
if (toys.optflags & FLAG_c) in++;
else *(out++) = *(in++);
if (FLAG(c)) in++;
else {
*(out++) = *(in++);
toys.exitval = 1;
}
inlen--;
}
if (out != outstart) xwrite(1, outstart, out-outstart);
Expand Down

0 comments on commit 53d8a67

Please sign in to comment.