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
0ca91482
Commit
0ca91482
authored
Mar 24, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing error checking in readdir() loops.
parent
c58071a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
src/port/copydir.c
src/port/copydir.c
+20
-1
src/port/dirmod.c
src/port/dirmod.c
+31
-2
No files found.
src/port/copydir.c
View file @
0ca91482
...
...
@@ -11,7 +11,7 @@
* as a service.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.1
0 2004/12/31 22:03:53 pgsq
l Exp $
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.1
1 2005/03/24 02:11:20 tg
l Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -56,6 +56,7 @@ copydir(char *fromdir, char *todir)
return
-
1
;
}
errno
=
0
;
while
((
xlde
=
readdir
(
xldir
))
!=
NULL
)
{
snprintf
(
fromfl
,
MAXPGPATH
,
"%s/%s"
,
fromdir
,
xlde
->
d_name
);
...
...
@@ -68,6 +69,24 @@ copydir(char *fromdir, char *todir)
FreeDir
(
xldir
);
return
-
1
;
}
errno
=
0
;
}
#ifdef WIN32
/*
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
* not in released version
*/
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
errno
=
0
;
#endif
if
(
errno
)
{
ereport
(
WARNING
,
(
errcode_for_file_access
(),
errmsg
(
"could not read directory
\"
%s
\"
: %m"
,
fromdir
)));
FreeDir
(
xldir
);
return
-
1
;
}
FreeDir
(
xldir
);
...
...
src/port/dirmod.c
View file @
0ca91482
...
...
@@ -10,7 +10,7 @@
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.3
6 2005/02/22 04:43:16 momjian
Exp $
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.3
7 2005/03/24 02:11:20 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -326,10 +326,19 @@ fnames(char *path)
dir
=
opendir
(
path
);
if
(
dir
==
NULL
)
{
#ifndef FRONTEND
elog
(
WARNING
,
"could not open directory
\"
%s
\"
: %m"
,
path
);
#else
fprintf
(
stderr
,
_
(
"could not open directory
\"
%s
\"
: %s
\n
"
),
path
,
strerror
(
errno
));
#endif
return
NULL
;
}
filenames
=
(
char
**
)
palloc
(
fnsize
*
sizeof
(
char
*
));
errno
=
0
;
while
((
file
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
file
->
d_name
,
"."
)
!=
0
&&
strcmp
(
file
->
d_name
,
".."
)
!=
0
)
...
...
@@ -342,6 +351,25 @@ fnames(char *path)
}
filenames
[
numnames
++
]
=
pstrdup
(
file
->
d_name
);
}
errno
=
0
;
}
#ifdef WIN32
/*
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
* not in released version
*/
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
errno
=
0
;
#endif
if
(
errno
)
{
#ifndef FRONTEND
elog
(
WARNING
,
"could not read directory
\"
%s
\"
: %m"
,
path
);
#else
fprintf
(
stderr
,
_
(
"could not read directory
\"
%s
\"
: %s
\n
"
),
path
,
strerror
(
errno
));
#endif
}
filenames
[
numnames
]
=
NULL
;
...
...
@@ -434,7 +462,8 @@ report_and_fail:
#ifndef FRONTEND
elog
(
WARNING
,
"could not remove file or directory
\"
%s
\"
: %m"
,
filepath
);
#else
fprintf
(
stderr
,
_
(
"could not remove file or directory
\"
%s
\"
: %s
\n
"
),
filepath
,
strerror
(
errno
));
fprintf
(
stderr
,
_
(
"could not remove file or directory
\"
%s
\"
: %s
\n
"
),
filepath
,
strerror
(
errno
));
#endif
fnames_cleanup
(
filenames
);
return
false
;
...
...
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