|
While adding validation for journal and w=0 or w=-1 conflict for CDRIVER-580, I noticed that parsing for values of w less than -1 are ignored apart from a logged error. This means that URI parsing can still succeed.
I don't think it's possible to fail during _mongoc_uri_build_write_concern(), which stores parsed options on the write concern struct, as that function provides no API for relaying an error upstream. That's why my PR in CDRIVER-580 validated the write concern one level up in mongoc_uri_new().
That said, I think we could easily catch an invalid w value in mongoc_uri_parse_option(), which does allow us to return false on an error. The relevant code segment would be:
if (*value == '-' || isdigit(*value)) {
|
v_int = (int) strtol (value, NULL, 10);
|
BSON_APPEND_INT32 (&uri->options, "w", v_int);
|
}
|
|