Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29472
Modified Files:
Tag: Feb2010
database.c utils.c
Log Message:
check return of fopen() in more places, as pointed out by Mark Bucciarelli
Index: database.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/database.c,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -d -r1.11 -r1.11.2.1
--- database.c 7 Jan 2010 15:24:31 -0000 1.11
+++ database.c 5 Mar 2010 14:42:39 -0000 1.11.2.1
@@ -118,11 +118,17 @@
/* put this database under maintenance, make sure no race condition
* ever can happen, by putting it under maintenance before it even
* exists for Merovingian */
- fclose(fopen(path, "w"));
+ if ((f = fopen(path, "w")) != NULL)
+ fclose(f); /* if this fails, below probably fails too */
/* avoid GDK making fugly complaints */
snprintf(path, sizeof(path), "%s/%s/.gdk_lock", dbfarm, dbname);
- f = fopen(path, "w");
+ if ((f = fopen(path, "w")) == NULL) {
+ snprintf(buf, sizeof(buf), "cannot write lock file: %s",
+ strerror(errno));
+ GDKfree(dbfarm);
+ return(strdup(buf));
+ }
/* to all insanity, .gdk_lock is "valid" if it contains a
* ':', which it does by pure coincidence of time having a
* ':' in there twice... */
Index: utils.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/utils.c,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -d -r1.23 -r1.23.2.1
--- utils.c 7 Jan 2010 15:24:31 -0000 1.23
+++ utils.c 5 Mar 2010 14:42:39 -0000 1.23.2.1
@@ -303,15 +303,22 @@
generatePassphraseFile(char *path)
{
FILE *f;
- char *buf = alloca(sizeof(char) * 48);
+ unsigned int len = 48;
+ char *buf[len];
- generateSalt(&buf, 48);
- f = fopen(path, "w");
- if (fwrite(buf, 1, 48, f) < 48) {
- snprintf(buf, sizeof(buf), "cannot write secret: %s",
+ generateSalt(buf, len);
+ if ((f = fopen(path, "w")) == NULL) {
+ char err[512];
+ snprintf(err, sizeof(err), "unable to open '%s': %s",
+ path, strerror(errno));
+ return(strdup(err));
+ }
+ if (fwrite(buf, 1, len, f) < len) {
+ char err[512];
+ snprintf(err, sizeof(err), "cannot write secret: %s",
strerror(errno));
fclose(f);
- return(strdup(buf));
+ return(strdup(err));
}
fclose(f);
return(NULL);
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins