Skip to content

Commit

Permalink
ctx_server.c: fix uninitialised memory access, resolves #28
Browse files Browse the repository at this point in the history
ctx_server.c:
- initialise output string memory to zero [resolves issue #28]
- add command prompt "> "

mccortex-server.py:
- strip prompt text from mccortex responses
- add example line to usage help

Update libraries
  • Loading branch information
noporpoise committed Jan 20, 2016
1 parent 67d6780 commit 2332b7f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libs/biogrok
Submodule biogrok updated 1 files
+0 −19 sam-base-count
2 changes: 1 addition & 1 deletion libs/bwa
Submodule bwa updated 1 files
+1 −1 bwakit/run-gen-ref
2 changes: 1 addition & 1 deletion libs/xxHash
Submodule xxHash updated 6 files
+9 −6 Makefile
+5 −3 README.md
+8 −6 cmake_unofficial/CMakeLists.txt
+139 −89 xxhash.c
+120 −57 xxhash.h
+157 −106 xxhsum.c
3 changes: 3 additions & 0 deletions scripts/mccortex-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def query_mccortex(proc,kmer):
proc.stdin.flush()
check_mccortex_alive(proc)
line = proc.stdout.readline()
# Trim off prompt text
if line[0:2] == "> ": line = line[2:len(line)]
check_mccortex_alive(proc)
return line

Expand Down Expand Up @@ -113,6 +115,7 @@ def do_GET(self):
def main():
if len(sys.argv) < 3 or not sys.argv[1].isdigit():
print("usage: %s <port> [mccortex args]" % (sys.argv[0]))
print(" e.g %s 1888 -m 2G graph.ctx" % (sys.argv[0]))
sys.exit(-1)

port = int(sys.argv[1])
Expand Down
11 changes: 7 additions & 4 deletions src/commands/ctx_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ static inline void kmer_response(StrBuf *resp, dBNode node, const char *keystr,

// Edges
Edges edges = db_node_get_edges_union(db_graph, node.key);
char edgesstr[9], left[5], right[5], *l, *r;
char edgesstr[9], left[5] = {0}, right[5] = {0}, *l = left, *r = right;
db_node_get_edges_str(edges, edgesstr);
for(l = left, i = 0; i < 4; i++)
for(i = 0; i < 4; i++)
if(edgesstr[i] != '.') { *l = toupper(edgesstr[i]); *(++l) = '\0'; }
for(r = right, i = 4; i < 8; i++)
for(i = 4; i < 8; i++)
if(edgesstr[i] != '.') { *r = edgesstr[i]; *(++r) = '\0'; }

strbuf_append_str(resp, "\"left\": \"");
Expand Down Expand Up @@ -371,8 +371,11 @@ int ctx_server(int argc, char **argv)
bool success;

// Read from input
while(futil_fcheck(strbuf_reset_readline(&line, stdin), stdin, "STDIN") > 0)
while(1)
{
fprintf(stdout, "> "); fflush(stdout);
if(futil_fcheck(strbuf_reset_readline(&line, stdin), stdin, "STDIN") == 0)
break;
strbuf_chomp(&line);
if(strcmp(line.b,"q") == 0) { break; }
else if(strcmp(line.b,"info") == 0) {
Expand Down

0 comments on commit 2332b7f

Please sign in to comment.