ArielGlenn has submitted this change and it was merged.
Change subject: sql2txt bug fixes
......................................................................
sql2txt bug fixes
- fix tab escaping where input size is not zero but we read past it
in the buffer, write right number of bytes out
- in sql_escape pay attention to (just) the size of input buf when
it's provided, not reading past it
- skip leading blanks before tuples
- make tab_escape and sql_escape take -1 size rather than 0
(which can be a legit size) in order to ignore that param
- deal properly with escaped chars split across buffers
- if we run out of data parsing a tuple, get a new buffer
Change-Id: I959ad9138394ee66a59487916be72620d9918447
---
M xmlfileutils/mwxmlelts.c
M xmlfileutils/sqlutils.c
2 files changed, 7 insertions(+), 6 deletions(-)
Approvals:
ArielGlenn: Verified; Looks good to me, approved
diff --git a/xmlfileutils/mwxmlelts.c b/xmlfileutils/mwxmlelts.c
index 660e11a..e37b7de 100644
--- a/xmlfileutils/mwxmlelts.c
+++ b/xmlfileutils/mwxmlelts.c
@@ -707,7 +707,7 @@
}
}
- sql_escape(r.comment,0,escaped_comment, sizeof(escaped_comment));
+ sql_escape(r.comment,-1,escaped_comment, sizeof(escaped_comment));
if (verbose > 1) {
fprintf(stderr,"revision info: id %s, parentid %s, timestamp %s, minor %s,
comment %s, sha1 %s, model %s, format %s, len %s, textid %s\n", r.id,
r.parent_id, r.timestamp, r.minor, escaped_comment, r.sha1, r.model, r.format,
r.text_len, r.text_id);
}
@@ -988,7 +988,7 @@
return(0);
}
}
- sql_escape(p.title,0, escaped_title, sizeof(escaped_title));
+ sql_escape(p.title,-1, escaped_title, sizeof(escaped_title));
title_escape(escaped_title);
/* we also need blank to _, see what else happens, woops */
if (verbose > 1) {
diff --git a/xmlfileutils/sqlutils.c b/xmlfileutils/sqlutils.c
index 03a1cc5..5720754 100644
--- a/xmlfileutils/sqlutils.c
+++ b/xmlfileutils/sqlutils.c
@@ -185,7 +185,7 @@
characters that are escaped are the below:
\x00, \n, \r, \, ', " and \x1a
- if s_size is 0, the string to escape mus be null terminated
+ if s_size is -1, the string to escape mus be null terminated
and its length is not checked.
*/
char *sql_escape(char *s, int s_size, char *out, int out_size) {
@@ -197,7 +197,7 @@
from = s;
to = out;
- while (*from || ind < s_size) {
+ while ((!s_size && *from) || ind < s_size) {
if (copied +3 > out_size) {
/* null terminate here and return index */
*to = '\0';
@@ -263,7 +263,7 @@
adding a trailing '\0' to the result (you should pass a string that
already has the remainder of the mysql escapes applied)
- if s_size is 0, the string to escape must be null terminated
+ if s_size is -1, the string to escape must be null terminated
and its length is not checked.
*/
char *tab_escape(char *s, int s_size, char *out, int out_size) {
@@ -275,7 +275,8 @@
from = s;
to = out;
- while (*from || ind < s_size) {
+
+ while ((s_size == -1 && *from) || ind < s_size) {
if (copied +3 > out_size) {
/* null terminate here and return index */
*to = '\0';
--
To view, visit https://gerrit.wikimedia.org/r/50172
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I959ad9138394ee66a59487916be72620d9918447
Gerrit-PatchSet: 1
Gerrit-Project: operations/dumps
Gerrit-Branch: ariel
Gerrit-Owner: ArielGlenn <[email protected]>
Gerrit-Reviewer: ArielGlenn <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits