Commit ccadfe49 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Double check that uses of snprintf inside brt code are OK. Refs #1508.

git-svn-id: file:///svn/toku/tokudb@9717 c7de825b-a66e-492c-adef-691d508d4ae1
parent e0259c8a
......@@ -757,9 +757,11 @@ int toku_serialize_brt_header_to (int fd, struct brt_header *h) {
toku_free(w_main.buf);
if (rr) {
if (h->panic==0) {
char s[200];
char *e = strerror(rr);
int l = 200 + strlen(e);
char s[l];
h->panic=rr;
snprintf(s, sizeof(s), "%s:%d: Error writing header to data file. errno=%d (%s)\n", __FILE__, __LINE__, rr, strerror(rr));
snprintf(s, l-1, "%s:%d: Error writing header to data file. errno=%d (%s)\n", __FILE__, __LINE__, rr, e);
h->panic_string = toku_strdup(s);
}
goto finish;
......
......@@ -385,18 +385,22 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, BLOCKNUM nodename, void *
int r = toku_graceful_dirty(cachefile);
if (r) {
if (h->panic==0) {
char s[200];
char *e = strerror(r);
int l = 200 + strlen(e);
char s[l];
h->panic=r;
snprintf(s, sizeof(s), "While creating dirty bit, error %d (%s)", r, strerror(r));
snprintf(s, l-1, "While creating dirty bit, error %d (%s)", r, e);
h->panic_string = toku_strdup(s);
}
}
r = toku_serialize_brtnode_to(toku_cachefile_fd(cachefile), brtnode->thisnodename, brtnode, h, n_workitems, n_threads);
if (r) {
if (h->panic==0) {
char s[200];
char *e = strerror(r);
int l = 200 + strlen(e);
char s[l];
h->panic=r;
snprintf(s, sizeof(s), "While writing data to disk, error %d (%s)", r, strerror(r));
snprintf(s, l-1, "While writing data to disk, error %d (%s)", r, e);
h->panic_string = toku_strdup(s);
}
}
......
......@@ -710,7 +710,8 @@ static int toku_delete_rolltmp_files (const char *log_dir) {
if (r==0) {
int fnamelen = strlen(log_dir) + strlen(de->d_name) + 2; // One for the slash and one for the trailing NUL.
char fname[fnamelen];
snprintf(fname, fnamelen, "%s/%s", log_dir, de->d_name);
int l = snprintf(fname, fnamelen, "%s/%s", log_dir, de->d_name);
assert(l+1 == fnamelen);
r = unlink(fname);
if (r!=0) {
result = errno;
......@@ -738,7 +739,8 @@ int tokudb_recover(const char *data_dir, const char *log_dir) {
int namelen=strlen(data_dir);
char lockfname[namelen+sizeof(fname)];
snprintf(lockfname, sizeof(lockfname), "%s%s", data_dir, fname);
int l = snprintf(lockfname, sizeof(lockfname), "%s%s", data_dir, fname);
assert(l+1 == (signed)(sizeof(lockfname)));
lockfd = toku_os_lock_file(lockfname);
if (lockfd<0) {
printf("Couldn't run recovery because some other process holds the recovery lock %s\n", lockfname);
......
......@@ -37,7 +37,7 @@ toku_rollback_fcreate (TXNID UU(xid),
int full_len=strlen(fname)+strlen(directory)+2;
char full_fname[full_len];
int l = snprintf(full_fname,full_len, "%s/%s", directory, fname);
assert(l<=full_len);
assert(l+1 == full_len);
//Remove reference to the fd in the cachetable
CACHEFILE cf;
int r = toku_cachefile_of_filenum(txn->logger->ct, filenum, &cf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment