diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2019-08-13 20:28:51 +0100 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2019-08-14 16:26:48 +0100 |
commit | dc414fde33f3ec22a6ae3cf29cfc6bc4a9ddae1a (patch) | |
tree | 56c1467c47fd45bdc2e3bad46b9b82b4186d4b8f /tools/klee-replay | |
parent | 8426b2913e650970d46be9a4d088bf3945f41453 (diff) | |
download | klee-dc414fde33f3ec22a6ae3cf29cfc6bc4a9ddae1a.tar.gz |
Replace sprintf with snprintf throughout codebase
Diffstat (limited to 'tools/klee-replay')
-rw-r--r-- | tools/klee-replay/file-creator.c | 17 | ||||
-rw-r--r-- | tools/klee-replay/klee-replay.c | 7 |
2 files changed, 12 insertions, 12 deletions
diff --git a/tools/klee-replay/file-creator.c b/tools/klee-replay/file-creator.c index 6e32630f..9b6e66a8 100644 --- a/tools/klee-replay/file-creator.c +++ b/tools/klee-replay/file-creator.c @@ -53,8 +53,7 @@ static int create_link(const char *fname, char buf[64]; struct stat64 *s = dfile->stat; - // XXX Broken, we want this path to be somewhere else most likely. - sprintf(buf, "%s.lnk", fname); + snprintf(buf, sizeof(buf), "%s.lnk", fname); s->st_mode = (s->st_mode & ~S_IFMT) | S_IFREG; create_file(-1, buf, dfile, tmpdir); @@ -335,9 +334,9 @@ static int delete_dir(const char *path, int recurse) { if (d) { while ((de = readdir(d))) { - if (strcmp(de->d_name, ".")!=0 && strcmp(de->d_name, "..")!=0) { + if (strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0) { char tmp[PATH_MAX]; - sprintf(tmp, "%s/%s", path, de->d_name); + snprintf(tmp, sizeof(tmp), "%s/%s", path, de->d_name); delete_file(tmp, 0); } } @@ -378,8 +377,8 @@ static void create_file(int target_fd, assert((target_fd == -1) ^ (target_name == NULL)); if (target_name) - sprintf(tmpname, "%s/%s", tmpdir, target_name); - else sprintf(tmpname, "%s/fd%d", tmpdir, target_fd); + snprintf(tmpname, sizeof(tmpname), "%s/%s", tmpdir, target_name); + else snprintf(tmpname, sizeof(tmpname), "%s/fd%d", tmpdir, target_fd); target = tmpname; @@ -418,7 +417,7 @@ static void create_file(int target_fd, // Only worry about 1 vs !1 if (s->st_nlink > 1) { char tmp2[PATH_MAX]; - sprintf(tmp2, "%s/%s.link2", tmpdir, target_name); + snprintf(tmp2, sizeof(tmp2), "%s/%s.link2", tmpdir, target_name); if (link(target_name, tmp2) < 0) { perror("link"); exit(1); @@ -449,7 +448,7 @@ void replay_create_files(exe_file_system_t *exe_fs) { umask(0); for (k=0; k < exe_fs->n_sym_files; k++) { char name[2]; - sprintf(name, "%c", 'A' + k); + snprintf(name, sizeof(name), "%c", 'A' + k); create_file(-1, name, &exe_fs->sym_files[k], tmpdir); } @@ -509,7 +508,7 @@ static void check_file(int index, exe_disk_file_t *dfile) { default: name[0] = 'A' + index; name[1] = '\0'; - sprintf(fullname, "%s/%s", replay_dir, name); + snprintf(fullname, sizeof(fullname), "%s/%s", replay_dir, name); res = stat(fullname, &s); break; diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c index f285ebf9..456c477d 100644 --- a/tools/klee-replay/klee-replay.c +++ b/tools/klee-replay/klee-replay.c @@ -69,7 +69,7 @@ static void stop_monitored(int process) { 0 }; char pids[64]; - sprintf(pids, "%d", process); + snprintf(pids, sizeof(pids), "%d", process); gdbargs[2] = pids; /* Make sure gdb doesn't talk to the user */ @@ -111,6 +111,7 @@ static void int_handler(int signal) { _exit(99); } } + static void timeout_handler(int signal) { fprintf(stderr, "KLEE-REPLAY: NOTE: EXIT STATUS: TIMED OUT (%d seconds)\n", monitored_timeout); @@ -139,7 +140,7 @@ void process_status(int status, time_t elapsed, const char *pfx) { if (rc == 0) { strcpy(msg, "NORMAL"); } else { - sprintf(msg, "ABNORMAL %d", rc); + snprintf(msg, sizeof(msg), "ABNORMAL %d", rc); } fprintf(stderr, "KLEE-REPLAY: NOTE: EXIT STATUS: %s (%d seconds)\n", msg, (int) elapsed); _exit(rc); @@ -406,7 +407,7 @@ int main(int argc, char** argv) { } -/* Klee functions */ +/* KLEE functions */ int __fputc_unlocked(int c, FILE *f) { return fputc_unlocked(c, f); |