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
e1b040a7
Commit
e1b040a7
authored
Aug 18, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix potential buffer overrun in cube_out(), per report from
Bruno Wolff.
parent
22bfa720
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
24 deletions
+21
-24
contrib/cube/cube.c
contrib/cube/cube.c
+19
-22
contrib/cube/cube.sql.in
contrib/cube/cube.sql.in
+2
-2
No files found.
contrib/cube/cube.c
View file @
e1b040a7
...
...
@@ -10,6 +10,7 @@
#include "access/gist.h"
#include "access/rtree.h"
#include "lib/stringinfo.h"
#include "utils/elog.h"
#include "utils/palloc.h"
#include "utils/builtins.h"
...
...
@@ -107,47 +108,43 @@ cube_in(char *str)
* char *out_func(char *);
*/
char
*
cube_out
(
NDBOX
*
cube
)
cube_out
(
NDBOX
*
cube
)
{
char
*
result
;
char
*
p
;
int
equal
=
1
;
StringInfoData
buf
;
bool
equal
=
true
;
int
dim
=
cube
->
dim
;
int
i
;
if
(
cube
==
NULL
)
return
(
NULL
);
p
=
result
=
(
char
*
)
palloc
(
100
);
initStringInfo
(
&
buf
);
/*
* while printing the first (LL) corner, check if it is equal to the
* scond one
* s
e
cond one
*/
p
+=
sprintf
(
p
,
"("
);
appendStringInfoChar
(
&
buf
,
'('
);
for
(
i
=
0
;
i
<
dim
;
i
++
)
{
p
+=
sprintf
(
p
,
"%g"
,
cube
->
x
[
i
]);
p
+=
sprintf
(
p
,
", "
);
if
(
i
>
0
)
appendStringInfo
(
&
buf
,
", "
);
appendStringInfo
(
&
buf
,
"%g"
,
cube
->
x
[
i
]);
if
(
cube
->
x
[
i
]
!=
cube
->
x
[
i
+
dim
])
equal
=
0
;
equal
=
false
;
}
p
-=
2
;
/* get rid of the last ", " */
p
+=
sprintf
(
p
,
")"
);
appendStringInfoChar
(
&
buf
,
')'
);
if
(
!
equal
)
{
p
+=
sprintf
(
p
,
",("
);
for
(
i
=
dim
;
i
<
dim
*
2
;
i
++
)
appendStringInfo
(
&
buf
,
",("
);
for
(
i
=
0
;
i
<
dim
;
i
++
)
{
p
+=
sprintf
(
p
,
"%g"
,
cube
->
x
[
i
]);
p
+=
sprintf
(
p
,
", "
);
if
(
i
>
0
)
appendStringInfo
(
&
buf
,
", "
);
appendStringInfo
(
&
buf
,
"%g"
,
cube
->
x
[
i
+
dim
]);
}
p
-=
2
;
p
+=
sprintf
(
p
,
")"
);
appendStringInfoChar
(
&
buf
,
')'
);
}
return
(
result
)
;
return
buf
.
data
;
}
...
...
contrib/cube/cube.sql.in
View file @
e1b040a7
...
...
@@ -8,12 +8,12 @@ SET search_path = public;
CREATE FUNCTION cube_in(opaque)
RETURNS opaque
AS 'MODULE_PATHNAME'
LANGUAGE 'c';
LANGUAGE 'c'
WITH (isStrict)
;
CREATE FUNCTION cube_out(opaque)
RETURNS opaque
AS 'MODULE_PATHNAME'
LANGUAGE 'c';
LANGUAGE 'c'
WITH (isStrict)
;
CREATE TYPE cube (
internallength = variable,
...
...
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