Skip to content

Commit

Permalink
nullcached fixes
Browse files Browse the repository at this point in the history
- fix off-by-one error in split_line()
- fix quit command
  • Loading branch information
mita committed Dec 25, 2009
1 parent 192c742 commit 97f8797
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nullcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static int command_type(const char *command)

static bool check_line(const char *line, size_t n)
{
return (line[n - 1] == '\r') && (line[n] == '\n');
return (n >= 2) && (line[n - 2] == '\r') && (line[n - 1] == '\n');
}

static void split_line(char *line, char **command, char **arguments)
Expand Down Expand Up @@ -246,7 +246,7 @@ static void process_retrieval_command(FILE *input, FILE *output, FILE *db,
static void process_other_command(FILE *input, FILE *output, FILE *db,
const char *command, const char *arguments)
{
if (strcmp(command, "quit"))
if (!strcmp(command, "quit"))
process_quit_command(input, output, db);
else
output_error(output);
Expand Down

0 comments on commit 97f8797

Please sign in to comment.