diff options
author | Trond Norbye <Trond.Norbye@gmail.com> | 2009-12-29 16:34:27 +0100 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2009-12-30 21:12:36 -0800 |
commit | cb10b041b38c79937ab070b0bd1941d4bf6f085e (patch) | |
tree | e507021c16d9dad0022a955d5642fc9d7edf8064 /testapp.c | |
parent | fcc093052812b8ee87bd954fcdb124f86f722385 (diff) | |
download | memcached-cb10b041b38c79937ab070b0bd1941d4bf6f085e.tar.gz |
Remove compile warnings on openBSD
Diffstat (limited to 'testapp.c')
-rw-r--r-- | testapp.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -271,7 +271,8 @@ static pid_t start_server(in_port_t *port_out, bool daemon, int timeout) { overwrite each other */ char coreadm[128]; - sprintf(coreadm, "coreadm -p core.%%f.%%p %lu", (unsigned long)getpid()); + snprintf(coreadm, sizeof(coreadm), + "coreadm -p core.%%f.%%p %lu", (unsigned long)getpid()); system(coreadm); #endif @@ -551,10 +552,11 @@ static enum test_return test_issue_102(void) { close(sock); sock = connect_server("127.0.0.1", port, false); - sprintf(buffer, "gets "); + snprintf(buffer, sizeof(buffer), "gets "); size_t offset = 5; while (offset < 4000) { - offset += sprintf(buffer + offset, "%010u ", (unsigned int)offset); + offset += snprintf(buffer + offset, sizeof(buffer) - offset, + "%010u ", (unsigned int)offset); } send_ascii_command(buffer); @@ -571,9 +573,10 @@ static enum test_return test_issue_102(void) { read_ascii_response(rsp, sizeof(rsp)); assert(strncmp(rsp, "END", strlen("END")) == 0); - - memset(buffer, ' ', 101); - strcat(buffer + 101, "gets foo"); + memset(buffer, ' ', sizeof(buffer)); + int len = snprintf(buffer + 101, sizeof(buffer) - 101, "gets foo"); + buffer[101 + len] = ' '; + buffer[sizeof(buffer) - 1] = '\0'; send_ascii_command(buffer); /* verify that the server closed the connection */ assert(read(sock, buffer, sizeof(buffer)) == 0); |