Dr. Werner Fink 2013-10-18 11:11:03 +00:00 committed by Git OBS Bridge
parent 25a6e9c8c2
commit cfaf1d1c78
2 changed files with 25 additions and 173 deletions

View File

@ -158,179 +158,6 @@
break;
case 'a':
all=1;
--- src/cmd/ksh93/edit/edit.c
+++ src/cmd/ksh93/edit/edit.c 2013-09-16 13:04:37.000000000 +0000
@@ -1414,12 +1414,12 @@ int ed_internal(const char *src, genchar
int ed_external(const genchar *src, char *dest)
{
register genchar wc;
- register int c,size;
register char *dp = dest;
char *dpmax = dp+sizeof(genchar)*MAXLINE-2;
if((char*)src == dp)
{
- char buffer[MAXLINE*sizeof(genchar)];
+ int c;
+ char buffer[MAXLINE*sizeof(genchar)] = "";
c = ed_external(src,buffer);
#ifdef _lib_wcscpy
@@ -1431,6 +1431,7 @@ int ed_external(const genchar *src, char
}
while((wc = *src++) && dp<dpmax)
{
+ ssize_t size;
if((size = mbconv(dp, wc)) < 0)
{
/* copy the character as is */
--- src/cmd/ksh93/edit/history.c
+++ src/cmd/ksh93/edit/history.c 2013-09-13 12:00:30.000000000 +0000
@@ -151,9 +151,9 @@ static History_t *hist_ptr;
(unsigned)acctfd < 10)
{
int n;
- if((n = fcntl(acctfd, F_DUPFD, 10)) >= 0)
+ if((n = sh_fcntl(acctfd, F_DUPFD_CLOEXEC, 10)) >= 0)
{
- close(acctfd);
+ sh_close(acctfd);
acctfd = n;
}
}
@@ -179,7 +179,7 @@ static int sh_checkaudit(History_t *hp,
{
char *cp, *last;
int id1, id2, r=0, n, fd;
- if((fd=open(name, O_RDONLY)) < 0)
+ if((fd=open(name, O_RDONLY|O_CLOEXEC)) < 0)
return(0);
if((n = read(fd, logbuf,len-1)) < 0)
goto done;
@@ -203,7 +203,7 @@ static int sh_checkaudit(History_t *hp,
}
while(*cp==';' || *cp==' ');
done:
- close(fd);
+ sh_close(fd);
return(r);
}
@@ -263,23 +263,23 @@ retry:
cp = path_relative(shp,histname);
if(!histinit)
histmode = S_IRUSR|S_IWUSR;
- if((fd=open(cp,O_BINARY|O_APPEND|O_RDWR|O_CREAT,histmode))>=0)
+ if((fd=open(cp,O_BINARY|O_APPEND|O_RDWR|O_CREAT|O_CLOEXEC,histmode))>=0)
{
hsize=lseek(fd,(off_t)0,SEEK_END);
}
if((unsigned)fd <=2)
{
int n;
- if((n=fcntl(fd,F_DUPFD,10))>=0)
+ if((n=sh_fcntl(fd,F_DUPFD_CLOEXEC,10))>=0)
{
- close(fd);
+ sh_close(fd);
fd=n;
}
}
/* make sure that file has history file format */
if(hsize && hist_check(fd))
{
- close(fd);
+ sh_close(fd);
hsize = 0;
if(unlink(cp)>=0)
goto retry;
@@ -294,7 +294,7 @@ retry:
{
if(!(fname = pathtmp(NIL(char*),0,0,NIL(int*))))
return(0);
- fd = open(fname,O_BINARY|O_APPEND|O_CREAT|O_RDWR,S_IRUSR|S_IWUSR);
+ fd = open(fname,O_BINARY|O_APPEND|O_CREAT|O_RDWR|O_CLOEXEC,S_IRUSR|S_IWUSR);
}
}
if(fd<0)
@@ -308,7 +308,7 @@ retry:
for(histmask=16;histmask <= maxlines; histmask <<=1 );
if(!(hp=new_of(History_t,(--histmask)*sizeof(off_t))))
{
- close(fd);
+ sh_close(fd);
return(0);
}
shgd->hist_ptr = hist_ptr = hp;
@@ -383,10 +383,10 @@ retry:
hp->auditfp = 0;
if(sh_isstate(SH_INTERACTIVE) && (hp->auditmask=sh_checkaudit(hp,SHOPT_AUDITFILE, buff, sizeof(buff))))
{
- if((fd=sh_open(buff,O_BINARY|O_WRONLY|O_APPEND|O_CREAT,S_IRUSR|S_IWUSR))>=0 && fd < 10)
+ if((fd=sh_open(buff,O_BINARY|O_WRONLY|O_APPEND|O_CREAT|O_CLOEXEC,S_IRUSR|S_IWUSR))>=0 && fd < 10)
{
int n;
- if((n = sh_fcntl(fd,F_DUPFD, 10)) >= 0)
+ if((n = sh_fcntl(fd,F_DUPFD_CLOEXEC, 10)) >= 0)
{
sh_close(fd);
fd = n;
@@ -425,7 +425,7 @@ void hist_close(register History_t *hp)
#if SHOPT_ACCTFILE
if(acctfd)
{
- close(acctfd);
+ sh_close(acctfd);
acctfd = 0;
}
#endif /* SHOPT_ACCTFILE */
@@ -470,7 +470,7 @@ static History_t* hist_trim(History_t *h
/* The unlink can fail on windows 95 */
int fd;
char *last, *name=hist_old->histname;
- close(sffileno(hist_old->histfp));
+ sh_close(sffileno(hist_old->histfp));
tmpname = (char*)malloc(strlen(name)+14);
if(last = strrchr(name,'/'))
{
@@ -485,7 +485,7 @@ static History_t* hist_trim(History_t *h
free(tmpname);
tmpname = name;
}
- fd = open(tmpname,O_RDONLY);
+ fd = open(tmpname,O_RDONLY|O_CLOEXEC);
sfsetfd(hist_old->histfp,fd);
if(tmpname==name)
tmpname = 0;
@@ -730,13 +730,13 @@ again:
if(last<0)
{
char buff[HIST_MARKSZ];
- int fd = open(hp->histname,O_RDWR);
+ int fd = open(hp->histname,O_RDWR|O_CLOEXEC);
if(fd>=0)
{
hist_marker(buff,hp->histind);
write(fd,(char*)hist_stamp,2);
write(fd,buff,HIST_MARKSZ);
- close(fd);
+ sh_close(fd);
}
}
last = 0;
@@ -1195,10 +1195,10 @@ static int hist_exceptf(Sfio_t* fp, int
if(errno==ENOSPC || hp->histwfail++ >= 10)
return(0);
/* write failure could be NFS problem, try to re-open */
- close(oldfd=sffileno(fp));
- if((newfd=open(hp->histname,O_BINARY|O_APPEND|O_CREAT|O_RDWR,S_IRUSR|S_IWUSR)) >= 0)
+ sh_close(oldfd=sffileno(fp));
+ if((newfd=open(hp->histname,O_BINARY|O_APPEND|O_CREAT|O_RDWR|O_CLOEXEC,S_IRUSR|S_IWUSR)) >= 0)
{
- if(fcntl(newfd, F_DUPFD, oldfd) !=oldfd)
+ if(sh_fcntl(newfd, F_DUPFD_CLOEXEC, oldfd) !=oldfd)
return(-1);
fcntl(oldfd,F_SETFD,FD_CLOEXEC);
close(newfd);
--- src/cmd/ksh93/include/defs.h
+++ src/cmd/ksh93/include/defs.h 2013-09-13 14:19:35.000000000 +0000
@@ -160,6 +160,7 @@ struct shared

View File

@ -18,6 +18,31 @@
goto done;
}
master->vm = vm;
--- src/cmd/ksh93/edit/edit.c
+++ src/cmd/ksh93/edit/edit.c 2013-09-16 13:04:37.000000000 +0000
@@ -1414,12 +1414,12 @@ int ed_internal(const char *src, genchar
int ed_external(const genchar *src, char *dest)
{
register genchar wc;
- register int c,size;
register char *dp = dest;
char *dpmax = dp+sizeof(genchar)*MAXLINE-2;
if((char*)src == dp)
{
- char buffer[MAXLINE*sizeof(genchar)];
+ int c;
+ char buffer[MAXLINE*sizeof(genchar)] = "";
c = ed_external(src,buffer);
#ifdef _lib_wcscpy
@@ -1431,6 +1431,7 @@ int ed_external(const genchar *src, char
}
while((wc = *src++) && dp<dpmax)
{
+ ssize_t size;
if((size = mbconv(dp, wc)) < 0)
{
/* copy the character as is */
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2013-10-10 10:44:39.762735998 +0000
@@ -1264,7 +1264,7 @@ Shell_t *sh_init(register int argc,regis