summaryrefslogtreecommitdiff
path: root/usr.bin/vim/memfile.c
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-09-21 06:23:56 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-09-21 06:23:56 +0000
commite8e01073071369d33ab4cf61be05bebe5a65566e (patch)
tree2c29b23bfb933e0fa40619f7d1fae430ff2c247e /usr.bin/vim/memfile.c
parent584e4bbf452da2934dbaf4b9dc09bd131a1d4cd7 (diff)
update to vim 4.4beta
Diffstat (limited to 'usr.bin/vim/memfile.c')
-rw-r--r--usr.bin/vim/memfile.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/vim/memfile.c b/usr.bin/vim/memfile.c
index 43022ab85be..1d05aa49655 100644
--- a/usr.bin/vim/memfile.c
+++ b/usr.bin/vim/memfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memfile.c,v 1.1 1996/09/07 21:40:26 downsj Exp $ */
+/* $OpenBSD: memfile.c,v 1.2 1996/09/21 06:23:07 downsj Exp $ */
/* vi:set ts=4 sw=4:
*
* VIM - Vi IMproved by Bram Moolenaar
@@ -130,7 +130,7 @@ mf_open(fname, trunc_file)
{
MEMFILE *mfp;
int i;
- long size;
+ off_t size;
#ifdef UNIX
struct STATFS stf;
#endif
@@ -346,6 +346,12 @@ mf_new(mfp, negative, page_count)
mf_ins_used(mfp, hp);
mf_ins_hash(mfp, hp);
+ /*
+ * Init the data to all zero, to avoid reading uninitialized data.
+ * This also avoids that the passwd file ends up in the swap file!
+ */
+ (void)vim_memset((char *)(hp->bh_data), 0, (size_t)mfp->mf_page_size);
+
return hp;
}
@@ -847,7 +853,7 @@ mf_read(mfp, hp)
MEMFILE *mfp;
BHDR *hp;
{
- long_u offset;
+ off_t offset;
unsigned page_size;
unsigned size;
@@ -857,7 +863,7 @@ mf_read(mfp, hp)
page_size = mfp->mf_page_size;
offset = page_size * hp->bh_bnum;
size = page_size * hp->bh_page_count;
- if ((long_u)lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
+ if (lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
{
EMSG("Seek error in swap file read");
return FAIL;
@@ -880,7 +886,7 @@ mf_write(mfp, hp)
MEMFILE *mfp;
BHDR *hp;
{
- long_u offset; /* offset in the file */
+ off_t offset; /* offset in the file */
blocknr_t nr; /* block nr which is being written */
BHDR *hp2;
unsigned page_size; /* number of bytes in a page */
@@ -914,7 +920,7 @@ mf_write(mfp, hp)
hp2 = hp;
offset = page_size * nr;
- if ((long_u)lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
+ if (lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
{
EMSG("Seek error in swap file write");
return FAIL;