Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
fcb9535e
Commit
fcb9535e
authored
Aug 06, 2007
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pg_restore to guard against unexpected EOF while reading an archive file.
Per report and partial patch from Chad Wagner.
parent
df9ea6a1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
20 deletions
+25
-20
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.c
+7
-5
src/bin/pg_dump/pg_backup_custom.c
src/bin/pg_dump/pg_backup_custom.c
+6
-5
src/bin/pg_dump/pg_backup_files.c
src/bin/pg_dump/pg_backup_files.c
+5
-4
src/bin/pg_dump/pg_backup_tar.c
src/bin/pg_dump/pg_backup_tar.c
+7
-6
No files found.
src/bin/pg_dump/pg_backup_archiver.c
View file @
fcb9535e
...
...
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.14
4 2007/03/26 16:58:39
tgl Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.14
5 2007/08/06 01:38:14
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1472,7 +1472,7 @@ ReadStr(ArchiveHandle *AH)
int
l
;
l
=
ReadInt
(
AH
);
if
(
l
==
-
1
)
if
(
l
<
0
)
buf
=
NULL
;
else
{
...
...
@@ -1480,7 +1480,9 @@ ReadStr(ArchiveHandle *AH)
if
(
!
buf
)
die_horribly
(
AH
,
modulename
,
"out of memory
\n
"
);
(
*
AH
->
ReadBufPtr
)
(
AH
,
(
void
*
)
buf
,
l
);
if
((
*
AH
->
ReadBufPtr
)
(
AH
,
(
void
*
)
buf
,
l
)
!=
l
)
die_horribly
(
AH
,
modulename
,
"unexpected end of file
\n
"
);
buf
[
l
]
=
'\0'
;
}
...
...
@@ -2675,8 +2677,8 @@ ReadHead(ArchiveHandle *AH)
/* If we haven't already read the header... */
if
(
!
AH
->
readHeader
)
{
(
*
AH
->
ReadBufPtr
)
(
AH
,
tmpMag
,
5
);
if
((
*
AH
->
ReadBufPtr
)
(
AH
,
tmpMag
,
5
)
!=
5
)
die_horribly
(
AH
,
modulename
,
"unexpected end of file
\n
"
);
if
(
strncmp
(
tmpMag
,
"PGDMP"
,
5
)
!=
0
)
die_horribly
(
AH
,
modulename
,
"did not find magic string in file header
\n
"
);
...
...
src/bin/pg_dump/pg_backup_custom.c
View file @
fcb9535e
...
...
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.3
8 2007/03/18 16:50:44 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.3
9 2007/08/06 01:38:14 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -712,7 +712,7 @@ _WriteByte(ArchiveHandle *AH, const int i)
*
* Called by the archiver to read bytes & integers from the archive.
* These routines are only used to read & write headers & TOC.
*
*
EOF should be treated as a fatal error.
*/
static
int
_ReadByte
(
ArchiveHandle
*
AH
)
...
...
@@ -720,9 +720,10 @@ _ReadByte(ArchiveHandle *AH)
lclContext
*
ctx
=
(
lclContext
*
)
AH
->
formatData
;
int
res
;
res
=
fgetc
(
AH
->
FH
);
if
(
res
!=
EOF
)
ctx
->
filePos
+=
1
;
res
=
getc
(
AH
->
FH
);
if
(
res
==
EOF
)
die_horribly
(
AH
,
modulename
,
"unexpected end of file
\n
"
);
ctx
->
filePos
+=
1
;
return
res
;
}
...
...
src/bin/pg_dump/pg_backup_files.c
View file @
fcb9535e
...
...
@@ -20,7 +20,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.3
2 2007/03/18 16:50:44 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.3
3 2007/08/06 01:38:15 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -395,9 +395,10 @@ _ReadByte(ArchiveHandle *AH)
lclContext
*
ctx
=
(
lclContext
*
)
AH
->
formatData
;
int
res
;
res
=
fgetc
(
AH
->
FH
);
if
(
res
!=
EOF
)
ctx
->
filePos
+=
1
;
res
=
getc
(
AH
->
FH
);
if
(
res
==
EOF
)
die_horribly
(
AH
,
modulename
,
"unexpected end of file
\n
"
);
ctx
->
filePos
+=
1
;
return
res
;
}
...
...
src/bin/pg_dump/pg_backup_tar.c
View file @
fcb9535e
...
...
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.5
8 2007/03/18 16:50:44 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.5
9 2007/08/06 01:38:15 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -510,7 +510,7 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, size_t len, TAR_MEMBER *th, FILE *fh)
used
=
avail
;
/* Copy, and adjust buffer pos */
memcpy
(
buf
,
AH
->
lookahead
,
used
);
memcpy
(
buf
,
AH
->
lookahead
+
AH
->
lookaheadPos
,
used
);
AH
->
lookaheadPos
+=
used
;
/* Adjust required length */
...
...
@@ -766,12 +766,13 @@ static int
_ReadByte
(
ArchiveHandle
*
AH
)
{
lclContext
*
ctx
=
(
lclContext
*
)
AH
->
formatData
;
int
res
;
char
c
=
'\0'
;
size_t
res
;
unsigned
char
c
;
res
=
tarRead
(
&
c
,
1
,
ctx
->
FH
);
if
(
res
!=
EOF
)
ctx
->
filePos
+=
res
;
if
(
res
!=
1
)
die_horribly
(
AH
,
modulename
,
"unexpected end of file
\n
"
);
ctx
->
filePos
+=
1
;
return
c
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment