Skip to content

Commit

Permalink
web100clt.c: make results parsing more robust
Browse files Browse the repository at this point in the history
1) Do not assume that the first line we receive contains a space

2) Do not assume that the first line we receive contains an integer

3) Be robust to the case where input is an empty string

4) Do not assume that after the first token delimited by space we
   will find a second token delimited by newline

Tested under the following conditions:

a) web100clt -n ndt.iupui.mlab1.trn01.measurement-lab.org that sends
   back all variables and checked via printf() that the variables that
   are parsed by the new code are the ones received in resultstr

b) web100clt -n neubot.mlab.mlab1.mil01.measurement-lab.org that at
   the moment is running botticelli v0.0.5 (which is buggy and doesn't
   send any MSG_RESULTS messages) and make sure it does not crash

c) web100clt -n neubot.mlab.mlab1.trn01.measurement-lab.org that at
   the moment is running botticelli v0.0.6 (which sends a single
   dummy variable not considered by NDT) and make sure it doesn't crash

Note that a) and c) did not changed after this patch. What this patch
changes is the behavior in case b).

xref: neubot/botticelli#18.
  • Loading branch information
bassosimone committed Jan 7, 2017
1 parent 6474520 commit 7137663
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/web100clt.c
Expand Up @@ -149,15 +149,12 @@ void testResults(char tests, char *testresult_str, char* host) {
}

sysvar = strtok(testresult_str, " ");
sysval = strtok(NULL, "\n");
i = atoi(sysval);
save_int_values(sysvar, i);

for (;;) {
sysvar = strtok(NULL, " ");
if (sysvar == NULL)
break;
sysval = strtok(NULL, "\n");
if (sysval == NULL)
break;
if (strchr(sysval, '.') == NULL) {
i = atoi(sysval);
save_int_values(sysvar, i);
Expand All @@ -167,6 +164,7 @@ void testResults(char tests, char *testresult_str, char* host) {
save_dbl_values(sysvar, &j);
log_println(7, "Stored %0.2f (%s) in %s", j, sysval, sysvar);
}
sysvar = strtok(NULL, " ");
}

// CountRTT = 615596;
Expand Down

0 comments on commit 7137663

Please sign in to comment.