Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bstrlib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
libraries
bstrlib
Commits
fcec18c164be
Commit
fcec18c164be
authored
9 years ago
by
websnarf
Browse files
Options
Downloads
Patches
Plain Diff
Fix from mike.steinert@gmail.com for uuDecode leak. Add bSGMLEncode().
parent
3f86efd84003
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bstraux.c
+21
-3
21 additions, 3 deletions
bstraux.c
bstraux.h
+1
-0
1 addition, 0 deletions
bstraux.h
testaux.c
+18
-0
18 additions, 0 deletions
testaux.c
with
40 additions
and
3 deletions
bstraux.c
+
21
−
3
View file @
fcec18c1
...
@@ -600,5 +600,7 @@
...
@@ -600,5 +600,7 @@
b
=
bfromcstralloc
(
256
,
""
);
b
=
bfromcstralloc
(
256
,
""
);
if
(
NULL
==
b
||
0
>
bsread
(
b
,
d
,
INT_MAX
))
{
if
(
NULL
==
b
||
0
>
bsread
(
b
,
d
,
INT_MAX
))
{
bdestroy
(
b
);
bdestroy
(
b
);
b
=
NULL
;
}
bsclose
(
d
);
bsclose
(
d
);
bsclose
(
s
);
bsclose
(
s
);
...
@@ -603,7 +605,5 @@
...
@@ -603,7 +605,5 @@
bsclose
(
d
);
bsclose
(
d
);
bsclose
(
s
);
bsclose
(
s
);
return
NULL
;
}
return
b
;
return
b
;
}
}
...
@@ -838,6 +838,24 @@
...
@@ -838,6 +838,24 @@
return
out
;
return
out
;
}
}
/* int bSGMLEncode (bstring b)
*
* Change the string into a version that is quotable in SGML (HTML, XML).
*/
int
bSGMLEncode
(
bstring
b
)
{
static
struct
tagbstring
fr
[
4
][
2
]
=
{
{
bsStatic
(
"&"
),
bsStatic
(
"&"
)
},
{
bsStatic
(
"
\"
"
),
bsStatic
(
"""
)
},
{
bsStatic
(
"<"
),
bsStatic
(
"<"
)
},
{
bsStatic
(
">"
),
bsStatic
(
">"
)
}
};
int
i
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
int
ret
=
bfindreplace
(
b
,
&
fr
[
i
][
0
],
&
fr
[
i
][
1
],
0
);
if
(
0
>
ret
)
return
ret
;
}
return
0
;
}
/* bstring bStrfTime (const char * fmt, const struct tm * timeptr)
/* bstring bStrfTime (const char * fmt, const struct tm * timeptr)
*
*
* Takes a format string that is compatible with strftime and a struct tm
* Takes a format string that is compatible with strftime and a struct tm
...
...
This diff is collapsed.
Click to expand it.
bstraux.h
+
1
−
0
View file @
fcec18c1
...
@@ -76,6 +76,7 @@
...
@@ -76,6 +76,7 @@
extern
bstring
bUuEncode
(
const_bstring
src
);
extern
bstring
bUuEncode
(
const_bstring
src
);
extern
bstring
bYEncode
(
const_bstring
src
);
extern
bstring
bYEncode
(
const_bstring
src
);
extern
bstring
bYDecode
(
const_bstring
src
);
extern
bstring
bYDecode
(
const_bstring
src
);
extern
int
bSGMLEncode
(
bstring
b
);
/* Writable stream */
/* Writable stream */
typedef
int
(
*
bNwrite
)
(
const
void
*
buf
,
size_t
elsize
,
size_t
nelem
,
void
*
parm
);
typedef
int
(
*
bNwrite
)
(
const
void
*
buf
,
size_t
elsize
,
size_t
nelem
,
void
*
parm
);
...
...
This diff is collapsed.
Click to expand it.
testaux.c
+
18
−
0
View file @
fcec18c1
...
@@ -379,6 +379,23 @@
...
@@ -379,6 +379,23 @@
return
ret
;
return
ret
;
}
}
int
test14_aux
(
bstring
b
,
const
char
*
chkVal
)
{
int
ret
=
0
;
ret
+=
0
!=
bSGMLEncode
(
b
);
ret
+=
1
!=
biseqcstr
(
b
,
chkVal
);
return
ret
;
}
int
test14
(
void
)
{
bstring
b
;
int
ret
=
0
;
printf
(
"TEST: bSGMLEncode.
\n
"
);
ret
+=
test14_aux
(
b
=
bfromStatic
(
"<
\"
Hello, you, me, & world
\"
>"
),
"<"Hello, you, me, & world">"
);
printf
(
"
\t
# failures: %d
\n
"
,
ret
);
return
ret
;
}
int
main
()
{
int
main
()
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -398,6 +415,7 @@
...
@@ -398,6 +415,7 @@
ret
+=
test11
();
ret
+=
test11
();
ret
+=
test12
();
ret
+=
test12
();
ret
+=
test13
();
ret
+=
test13
();
ret
+=
test14
();
printf
(
"# test failures: %d
\n
"
,
ret
);
printf
(
"# test failures: %d
\n
"
,
ret
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment