Changeset: 1ed011aa3aec for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1ed011aa3aec
Modified Files:
gdk/gdk_bbp.mx
Branch: Apr2011
Log Message:
Added checks to BBPimportEntry.
This should alleviate bug 2751: it now fails with an error message
instead of causing a crash.
diffs (73 lines):
diff --git a/gdk/gdk_bbp.mx b/gdk/gdk_bbp.mx
--- a/gdk/gdk_bbp.mx
+++ b/gdk/gdk_bbp.mx
@@ -906,12 +906,16 @@
a BATdescriptor using symbolic links to its source. Presumably this would lead
to a transparent behavior.
@= linkHeap
- lstat(@3, &st);
+ if (lstat(@3, &st) < 0) {
+ GDKerror("BBPimportEntry: file '%s' does not exist.\n", @3);
+ BBPdestroy(bn);
+ return 0;
+ }
GDKfilepath(path, BATDIR, BBP_physical(bn->batCacheid), "@4");
GDKcreatedir(path);
IODEBUG mnstr_printf(GDKerr, "#symlink %s ->%s\n", @3, path);
if (symlink(@3, path) < 0) {
- GDKerror("attach.bind:cannot link '%s' -> '%s'\n", path, @3);
+ GDKerror("BBPimportEntry: cannot link '%s' -> '%s'\n", path,
@3);
BBPdestroy(bn);
return 0;
}
@@ -921,15 +925,23 @@
GDKfree(bn->@1->@2.filename);
bn->@1->@2.filename = 0;
}
- HEAPload(&bn->@1->@2, BBP_physical(bn->batCacheid), "@4", TRUE);
+ if (HEAPload(&bn->@1->@2, BBP_physical(bn->batCacheid), "@4", TRUE) <
0) {
+ GDKerror("BBPimportEntry: cannot read heap file '%s'\n", @3);
+ BBPdestroy(bn);
+ return 0;
+ }
@= linkvHeap
- lstat(@2, &st);
+ if (lstat(@2, &st) < 0) {
+ GDKerror("BBPimportEntry: file '%s' does not exist.\n", @2);
+ BBPdestroy(bn);
+ return 0;
+ }
GDKfilepath(path, BATDIR, BBP_physical(bn->batCacheid), "@3");
GDKcreatedir(path);
IODEBUG mnstr_printf(GDKerr, "#symlink %s ->%s\n", @2, path);
if (symlink(@2, path) < 0) {
- GDKerror("attach.bind:cannot link '%s' -> '%s'\n", path, @2);
+ GDKerror("BBPimportEntry: cannot link '%s' -> '%s'\n", path,
@2);
BBPdestroy(bn);
return 0;
}
@@ -942,7 +954,11 @@
GDKfree(bn->@1->vheap->filename);
bn->@1->vheap->filename = 0;
}
- HEAPload(bn->@1->vheap, BBP_physical(bn->batCacheid), "@3", TRUE);
+ if (HEAPload(bn->@1->vheap, BBP_physical(bn->batCacheid), "@3", TRUE) <
0) {
+ GDKerror("BBPimportEntry: cannot read heap file '%s'\n", @2);
+ BBPdestroy(bn);
+ return 0;
+ }
@c
bat
@@ -968,6 +984,10 @@
int BBPlimit;
IODEBUG mnstr_printf(GDKerr,"#importEntry %s\n",nme);
+ if (strlen(nme) >= sizeof(bbpdir)) {
+ GDKerror("BBPimportEntry: file name too long\n");
+ return 0;
+ }
strcpy(bbpdir,nme);
s= strstr(bbpdir,BATDIR);
if (s == 0)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list