The Samba-Bugzilla – Attachment 9078 Details for
Bug 10033
call to mmap() not checked for failure in shared_mmap.c
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Corrects file for README.Coding standard
incoherent_mmap.c.patch (text/plain), 1.81 KB, created by
Bill Parker
on 2013-07-26 19:56:19 UTC
(
hide
)
Description:
Corrects file for README.Coding standard
Filename:
MIME Type:
Creator:
Bill Parker
Created:
2013-07-26 19:56:19 UTC
Size:
1.81 KB
patch
obsolete
>--- incoherent_mmap.c.orig 2013-07-24 18:19:19.852549061 -0700 >+++ incoherent_mmap.c 2013-07-24 18:21:20.779548719 -0700 >@@ -22,15 +22,18 @@ > const char *fname = argv[1]; > char c = 0; > >- if (pipe(tochild) != 0 || pipe(toparent) != 0) >+ if (pipe(tochild) != 0 || pipe(toparent) != 0) { > err(2, "Creating pipe"); >+ } > >- if (!fname) >+ if (!fname) { > fname = DATA; >+ } > > fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600); >- if (fd < 0) >+ if (fd < 0) { > err(2, "opening %s", fname); >+ } > unlink(fname); > > switch (fork()) { >@@ -41,14 +44,16 @@ > close(toparent[0]); > > /* Wait for parent to create file. */ >- if (read(tochild[0], &c, 1) != 1) >+ if (read(tochild[0], &c, 1) != 1) { > err(2, "reading from parent"); >+ } > > /* Alter first byte. */ > pwrite(fd, &c, 1, 0); > >- if (write(toparent[1], &c, 1) != 1) >+ if (write(toparent[1], &c, 1) != 1) { > err(2, "writing to parent"); >+ } > exit(0); > > default: >@@ -58,25 +63,31 @@ > /* Create a file and mmap it. */ > page = malloc(getpagesize()); > memset(page, 0x42, getpagesize()); >- if (write(fd, page, getpagesize()) != getpagesize()) >+ if (write(fd, page, getpagesize()) != getpagesize()) { > err(2, "writing first page"); >+ } > map = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, > MAP_SHARED, fd, 0); >- if (map == MAP_FAILED) >+ if (map == MAP_FAILED) { > err(2, "mapping file"); >+ } > >- if (*map != 0x42) >+ if (*map != 0x42) { > errx(2, "first byte isn't 0x42!"); >+ } > > /* Tell child to alter file. */ >- if (write(tochild[1], &c, 1) != 1) >+ if (write(tochild[1], &c, 1) != 1) { > err(2, "writing to child"); >+ } > >- if (read(toparent[0], &c, 1) != 1) >+ if (read(toparent[0], &c, 1) != 1) { > err(2, "reading from child"); >+ } > >- if (*map) >+ if (*map) { > errx(0, "mmap incoherent: first byte isn't 0."); >+ } > > exit(1); > }
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 Raw
Flags:
wp02855
:
review?
Actions:
View
Attachments on
bug 10033
:
9058
|
9077
| 9078 |
9079
|
9080
|
9081