mirror of https://github.com/ArduPilot/ardupilot
mavlink: fixed parameter string handling
this prevents running past the end of a non-terminated string. git-svn-id: https://arducopter.googlecode.com/svn/trunk@1740 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
26066291cb
commit
3b19ab773d
|
@ -551,7 +551,10 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// set parameter
|
// set parameter
|
||||||
const char * key = (const char*) packet.param_id;
|
|
||||||
|
char key[ONBOARD_PARAM_NAME_LENGTH+1];
|
||||||
|
strncpy(key, (char *)packet.param_id, ONBOARD_PARAM_NAME_LENGTH);
|
||||||
|
key[ONBOARD_PARAM_NAME_LENGTH] = 0;
|
||||||
|
|
||||||
// find the requested parameter
|
// find the requested parameter
|
||||||
vp = AP_Var::find(key);
|
vp = AP_Var::find(key);
|
||||||
|
@ -581,13 +584,9 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report back new value
|
// Report back new value
|
||||||
char param_name[ONBOARD_PARAM_NAME_LENGTH]; // XXX HACK - need something to return a char *
|
mavlink_msg_param_value_send(chan, (int8_t *)key, packet.param_value,
|
||||||
vp->copy_name(param_name, sizeof(param_name));
|
_count_parameters(),
|
||||||
mavlink_msg_param_value_send(chan,
|
-1); // XXX we don't actually know what its index is...
|
||||||
(int8_t*)param_name,
|
|
||||||
packet.param_value,
|
|
||||||
_count_parameters(),
|
|
||||||
-1); // XXX we don't actually know what its index is...
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} // end case
|
} // end case
|
||||||
|
|
Loading…
Reference in New Issue