Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 1319143 Details for
Bug 1464409
shp.fdstatus may be accessed with -1 offset, corrupting last element of shp.fdptrs
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh90 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Fix memory corruption caused by accessing array with negative index
ksh-20120801-sh_iovalidfd.patch (text/plain), 2.12 KB, created by
Siteshwar Vashisht
on 2017-08-28 16:09:04 UTC
(
hide
)
Description:
Fix memory corruption caused by accessing array with negative index
Filename:
MIME Type:
Creator:
Siteshwar Vashisht
Created:
2017-08-28 16:09:04 UTC
Size:
2.12 KB
patch
obsolete
>diff --git a/src/cmd/ksh93/include/io.h b/src/cmd/ksh93/include/io.h >--- a/src/cmd/ksh93/include/io.h >+++ b/src/cmd/ksh93/include/io.h >@@ -79,7 +79,7 @@ extern Sfio_t *sh_iostream(Shell_t*,int); > extern int sh_redirect(Shell_t*,struct ionod*,int); > extern void sh_iosave(Shell_t *, int,int,char*); > extern int safefdnumber(Shell_t* shp, int sfd); >-extern int sh_iovalidfd(Shell_t*, int); >+extern bool sh_iovalidfd(Shell_t*, int); > extern int sh_inuse(Shell_t*, int); > extern void sh_iounsave(Shell_t*); > extern void iounpipe(Shell_t*); >diff --git a/src/cmd/ksh93/sh/io.c b/src/cmd/ksh93/sh/io.c >--- a/src/cmd/ksh93/sh/io.c >+++ b/src/cmd/ksh93/sh/io.c >@@ -403,38 +403,50 @@ static short filemapsize; > > /* ======== input output and file copying ======== */ > >-int sh_iovalidfd(Shell_t *shp, int fd) >+bool sh_iovalidfd(Shell_t *shp, int fd) > { > Sfio_t **sftable = shp->sftable; > int max,n, **fdptrs = shp->fdptrs; > unsigned char *fdstatus = shp->fdstatus; > if(fd<0) >- return(0); >+ return(false); > if(fd < shp->gd->lim.open_max) >- return(1); >+ return(true); > max = strtol(astconf("OPEN_MAX",NiL,NiL),NiL,0); > if(fd >= max) > { > errno = EBADF; >- return(0); >+ return(false); > } > n = (fd+16)&~0xf; >- if(n > max) >- n = max; >+ if(n++ > max) >+ n = max+1; > max = shp->gd->lim.open_max; >- shp->sftable = (Sfio_t**)calloc((n+1)*(sizeof(int*)+sizeof(Sfio_t*)+1),1); >- if(max) >- memcpy(shp->sftable,sftable,max*sizeof(Sfio_t*)); >+ shp->sftable = (Sfio_t**)calloc((n+1)*(sizeof(int*)+sizeof(Sfio_t*)+sizeof(*fdstatus)),1); >+ >+ if(sftable) >+ { >+ --sftable; >+ if(max) >+ memcpy(shp->sftable,sftable,++max*sizeof(Sfio_t*)); >+ >+ } >+ > shp->fdptrs = (int**)(&shp->sftable[n]); > if(max) >- memcpy(shp->fdptrs,fdptrs,max*sizeof(int*)); >+ memcpy(shp->fdptrs,--fdptrs,max*sizeof(int*)); > shp->fdstatus = (unsigned char*)(&shp->fdptrs[n]); > if(max) >- memcpy(shp->fdstatus,fdstatus,max); >+ memcpy(shp->fdstatus,--fdstatus,max); >+ > if(sftable) > free((void*)sftable); >- shp->gd->lim.open_max = n; >- return(1); >+ >+ shp->sftable++; >+ shp->fdptrs++; >+ shp->fdstatus++; >+ shp->gd->lim.open_max = n-1; >+ return(true); > } > > int sh_inuse(Shell_t *shp, int fd)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
kdudka
: review+
Actions:
View
|
Diff
Attachments on
bug 1464409
:
1319079
| 1319143