|
From: Chris B. <buc...@us...> - 2012-03-08 22:14:47
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SFCB - Small Footprint CIM Broker".
The branch, master has been updated
via e59f10745266bb5513953f51e8cbd3135a7fb65d (commit)
from 727cf3bdd65a052d974edb2743b396b43f2eadd0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e59f10745266bb5513953f51e8cbd3135a7fb65d
Author: buccella <buc...@li...>
Date: Thu Mar 8 17:14:32 2012 -0500
[ 3499930 ] Check file repository writes
-----------------------------------------------------------------------
Summary of changes:
diff --git a/ChangeLog b/ChangeLog
index 47af6ea..3693efb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2012-03-08 Chris Buccella <buc...@li...>
+ * fileRepository.c:
+ [ 3499930 ] Check file repository writes
+
* httpAdapter.c, cimRequest.c, sfcBroker.c:
[ 3440300 ] Allow forced chunked responses
[ 3492362 ] Problem with whitespace trimming if local connect only
diff --git a/NEWS b/NEWS
index 10427f1..ab28e81 100644
--- a/NEWS
+++ b/NEWS
@@ -114,6 +114,7 @@ Bugs Fixed:
- 3498275 Remove __Namespace
- 3426027 cimAccountPassThrough does not set return code
- 3492362 Problem with whitespace trimming if local connect only
+- 3499930 Check file repository writes
Changes in 1.3.13
=================
diff --git a/fileRepository.c b/fileRepository.c
index c9b85f7..832e510 100644
--- a/fileRepository.c
+++ b/fileRepository.c
@@ -410,7 +410,8 @@ rebuild(BlobIndex * bi, const char *id, void *blob, int blen)
int ofs,
len,
xt = 0,
- dt = 0;
+ dt = 0,
+ rc = 0;
unsigned long pos;
char *xn = alloca(strlen(bi->dir) + 8);
char *dn = alloca(strlen(bi->dir) + 8);
@@ -433,21 +434,24 @@ rebuild(BlobIndex * bi, const char *id, void *blob, int blen)
dt += len;
pos = ftell(d);
if (blen)
- fwrite(blob, blen, 1, d);
+ rc = fwrite(blob,blen,1,d) - 1;
dt += blen;
- fclose(d);
+ rc += fclose(d);
+ if (rc != 0) return -1;
+
adjust(bi, bi->pos, bi->blen);
ofs = bi->pos + bi->len;
if (bi->pos)
- fwrite(bi->index, bi->pos, 1, x);
+ rc += fwrite(bi->index, bi->pos, 1, x) - 1;
xt += bi->pos;
len = bi->dSize - ofs;
if (len)
- fwrite(bi->index + ofs, len, 1, x);
+ rc += fwrite(bi->index + ofs, len, 1, x) - 1;
xt += len;
- fclose(x);
+ rc += fclose(x);
+ if (rc != 0) return -1;
remove(bi->fnd);
remove(bi->fnx);
@@ -547,9 +551,13 @@ addBlob(const char *ns, const char *cls, char *id, void *blob, int len)
fdHandleError(bi);
return -1;
}
- fwrite(blob, len, 1, bi->fd);
- fclose(bi->fd);
+ rc = fwrite(blob,len,1,bi->fd) - 1; /* write the serialized instance */
+ rc += fclose(bi->fd);
bi->fd = NULL;
+ if (rc != 0) {
+ fdHandleError(bi);
+ return -1;
+ }
es = sprintf(idxe, " %zd %s %d %d\r\n", strlen(id), id, len, 0);
ep = sprintf(idxe, "%d", es);
@@ -557,14 +565,18 @@ addBlob(const char *ns, const char *cls, char *id, void *blob, int len)
memcpy(bi->index, idxe, es);
bi->dSize = es;
- fwrite(bi->index, bi->dSize, 1, bi->fx);
- fclose(bi->fx);
+ rc = fwrite(bi->index,bi->dSize,1,bi->fx) - 1; /* write idx file */
+ rc += fclose(bi->fx);
bi->fx = NULL;
+ if (rc != 0) {
+ fdHandleError(bi);
+ return -1;
+ }
}
else {
- if (indxLocate(bi, id)) {
+ if (indxLocate(bi,id)) { /* already have entries in the idx file; append */
bi->fd = fopen(bi->fnd, "rb");
if (bi->fd == NULL) {
fdHandleError(bi);
@@ -578,19 +590,23 @@ addBlob(const char *ns, const char *cls, char *id, void *blob, int len)
idxe[ep] = ' ';
memcpy(bi->index + bi->dSize, idxe, es);
bi->dSize += es;
- rebuild(bi, id, blob, len);
+ if (rebuild(bi,id,blob,len) != 0) { fdHandleError(bi); return -1; }
}
}
- else {
+ else { /* first entry in the idx file */
bi->fd = fopen(bi->fnd, "ab+");
if (bi->fd == NULL)
bi->fd = fopen(bi->fnd, "wb+");
fseek(bi->fd, 0, SEEK_END);
bi->fpos = ftell(bi->fd);
- fwrite(blob, len, 1, bi->fd);
- fclose(bi->fd);
+ rc = fwrite(blob,len,1,bi->fd) - 1;
+ rc += fclose(bi->fd);
bi->fd = NULL;
+ if (rc != 0) {
+ fdHandleError(bi);
+ return -1;
+ }
es = sprintf(idxe, " %zd %s %d %lu\r\n", strlen(id), id, len,
bi->fpos);
@@ -600,8 +616,8 @@ addBlob(const char *ns, const char *cls, char *id, void *blob, int len)
memcpy(bi->index + bi->dSize, idxe, es);
bi->dSize += es;
fseek(bi->fx, 0, SEEK_SET);
- fwrite(bi->index, bi->dSize, 1, bi->fx);
- fclose(bi->fx);
+ rc = fwrite(bi->index,bi->dSize,1,bi->fx) - 1;
+ rc += fclose(bi->fx);
bi->fx = NULL;
}
}
@@ -628,7 +644,7 @@ deleteBlob(const char *ns, const char *cls, const char *id)
} else {
fseek(bi->fd, 0, SEEK_END);
bi->dlen = ftell(bi->fd);
- rebuild(bi, id, NULL, 0);
+ if (rebuild(bi,id,NULL,0) != 0) { fdHandleError(bi); return -1; }
freeBlobIndex(&bi, 1);
return 0;
}
hooks/post-receive
--
SFCB - Small Footprint CIM Broker
|