Subject: | getData buffer overrun |
Sedna-0.004 Mac OSX 10.5.8 (Darwin 9.8.0) / Perl 5.10.0
Symptom:
calls to getData crash with "bus error"
Reproduce (see attached):
perl test_sedna.pl 1
Patch (attached):
--- SednaOld.xs 2012-10-16 16:00:52.000000000 +0100
+++ Sedna.xs 2012-10-16 15:53:39.000000000 +0100
@@ -372,11 +372,12 @@
int reqlen
CODE:
SvUTF8_off(svbuff);
- char* buff = SvGROW(svbuff, reqlen+10);
- int ret = SEgetData(conn, buff, reqlen);
+ char* buff = malloc(reqlen);
+ int ret = SEgetData(conn, buff, reqlen-1);
if (ret < 0) {
croak("error at SEgetData: %s", SEgetLastErrorMsg(conn));
} else {
+ sv_catpv(svbuff,buff);
RETVAL = ret;
}
OUTPUT:
Subject: | mods.diff |
--- SednaOld.xs 2012-10-16 16:00:52.000000000 +0100
+++ Sedna.xs 2012-10-16 15:53:39.000000000 +0100
@@ -372,11 +372,12 @@
int reqlen
CODE:
SvUTF8_off(svbuff);
- char* buff = SvGROW(svbuff, reqlen+10);
- int ret = SEgetData(conn, buff, reqlen);
+ char* buff = malloc(reqlen);
+ int ret = SEgetData(conn, buff, reqlen-1);
if (ret < 0) {
croak("error at SEgetData: %s", SEgetLastErrorMsg(conn));
} else {
+ sv_catpv(svbuff,buff);
RETVAL = ret;
}
OUTPUT: