harden the crlf vs lf tests even more; use binary mode explicitly on OS/2

This commit is contained in:
tg
2015-07-09 20:52:43 +00:00
parent dcd8b6389b
commit edf76ec8e6
10 changed files with 80 additions and 43 deletions

8
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.158 2015/07/09 20:20:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.159 2015/07/09 20:52:38 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -925,7 +925,7 @@ scriptexec(struct op *tp, const char **ap)
*tp->args-- = tp->str;
#ifndef MKSH_SMALL
if ((fd = open(tp->str, O_RDONLY | O_BINARY)) >= 0) {
if ((fd = binopen2(tp->str, O_RDONLY)) >= 0) {
unsigned char *cp;
unsigned short m;
ssize_t n;
@ -1445,7 +1445,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
warningf(true, "%s: %s", cp, "restricted");
return (-1);
}
u = open(cp, flags | O_BINARY, 0666);
u = binopen3(cp, flags, 0666);
}
if (u < 0) {
/* herein() may already have printed message */
@ -1578,7 +1578,7 @@ herein(struct ioword *iop, char **resbuf)
* so temp doesn't get removed too soon).
*/
h = maketemp(ATEMP, TT_HEREDOC_EXP, &e->temps);
if (!(shf = h->shf) || (fd = open(h->tffn, O_RDONLY | O_BINARY, 0)) < 0) {
if (!(shf = h->shf) || (fd = binopen3(h->tffn, O_RDONLY, 0)) < 0) {
i = errno;
warningf(true, "can't %s temporary file %s: %s",
!shf ? "create" : "open", h->tffn, cstrerror(i));