/*authenticatorIndex*/
json_builder_set_member_name(builder, _JSON_KEY_AUTH_INDEX);
int auth_index_int = -1;
- sscanf(auth_index, "%d", &auth_index_int);
+ char *end;
+ long sl;
+
+ sl = strtol(auth_index, &end, 10);
+ if (end == auth_index) {
+ _ERR("Failed to compose get registration reqeust");
+ } else if ('\0' != *end) {
+ _ERR("Failed to compose get registration reqeust");
+ } else if ((LONG_MIN == sl || LONG_MAX == sl) && ERANGE == errno) {
+ _ERR("Failed to compose get registration reqeust");
+ } else if (sl > INT_MAX) {
+ _ERR("Failed to compose get registration reqeust");
+ } else if (sl < INT_MIN) {
+ _ERR("Failed to compose get registration reqeust");
+ } else {
+ auth_index_int = (int)sl;
+ }
+
json_builder_add_int_value(builder, auth_index_int);
reg_in->final_challenge = fc_json;
int auth_idx_int = -1;
- sscanf(matched_auth->auth_index, "%d", &auth_idx_int);
+ char *end;
+ long sl;
+
+ sl = strtol(matched_auth->auth_index, &end, 10);
+ if (end == matched_auth->auth_index) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ _free_fido_asm_reg_in(reg_in);
+ return;
+ } else if ('\0' != *end) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ _free_fido_asm_reg_in(reg_in);
+ return;
+ } else if ((LONG_MIN == sl || LONG_MAX == sl) && ERANGE == errno) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ _free_fido_asm_reg_in(reg_in);
+ return;
+ } else if (sl > INT_MAX) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ _free_fido_asm_reg_in(reg_in);
+ return;
+ } else if (sl < INT_MIN) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ _free_fido_asm_reg_in(reg_in);
+ return;
+ } else {
+ auth_idx_int = (int)sl;
+ }
reg_in->attestation_type = matched_auth->att_type;
version->minor = _VERSION_MINOR;
int auth_idx_int = -1;
- sscanf(matched_auth->auth_index, "%d", &auth_idx_int);
+ char *end;
+ long sl;
+
+ sl = strtol(matched_auth->auth_index, &end, 10);
+ if (end == matched_auth->auth_index) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ SAFE_DELETE(version);
+ return;
+ } else if ('\0' != *end) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ SAFE_DELETE(version);
+ return;
+ } else if ((LONG_MIN == sl || LONG_MAX == sl) && ERANGE == errno) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ SAFE_DELETE(version);
+ return;
+ } else if (sl > INT_MAX) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ SAFE_DELETE(version);
+ return;
+ } else if (sl < INT_MIN) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ SAFE_DELETE(version);
+ return;
+ } else {
+ auth_idx_int = (int)sl;
+ }
+
if (auth_idx_int == -1) {
_ERR("ASM in data missing");
_send_process_response(cb_data, FIDO_ERROR_NO_SUITABLE_AUTHENTICATOR, NULL);
char *asm_req_json = NULL;
int auth_index_int = _INVALID_INT;
- sscanf(dereg_data->auth_index, "%d", &auth_index_int);
+ char *end;
+ long sl;
+
+ sl = strtol(dereg_data->auth_index, &end, 10);
+ if (end == dereg_data->auth_index) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ return;
+ } else if ('\0' != *end) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ return;
+ } else if ((LONG_MIN == sl || LONG_MAX == sl) && ERANGE == errno) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ return;
+ } else if (sl > INT_MAX) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ return;
+ } else if (sl < INT_MIN) {
+ _ERR("Failed to compose final challenge");
+ _send_process_response(cb_data, FIDO_ERROR_PROTOCOL_ERROR, NULL);
+ return;
+ } else {
+ auth_index_int = (int)sl;
+ }
_INFO("Auth index for dereg req = [%d]", auth_index_int);