mirror of https://github.com/ARMmbed/mbed-os.git
Fixed bug when copying apn, username and password.
parent
9016ed5ed8
commit
0c49b669b4
|
@ -80,7 +80,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||||
if (apn && (len = strlen(apn)) > 0) {
|
if (apn && (len = strlen(apn)) > 0) {
|
||||||
_apn = (char*)malloc(len*sizeof(char)+1);
|
_apn = (char*)malloc(len*sizeof(char)+1);
|
||||||
if (_apn) {
|
if (_apn) {
|
||||||
memcpy(_apn, apn, len);
|
memcpy(_apn, apn, len+1);
|
||||||
} else {
|
} else {
|
||||||
return NSAPI_ERROR_NO_MEMORY;
|
return NSAPI_ERROR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||||
if (username && (len = strlen(username)) > 0) {
|
if (username && (len = strlen(username)) > 0) {
|
||||||
_uname = (char*)malloc(len*sizeof(char)+1);
|
_uname = (char*)malloc(len*sizeof(char)+1);
|
||||||
if (_uname) {
|
if (_uname) {
|
||||||
memcpy(_uname, username, len);
|
memcpy(_uname, username, len+1);
|
||||||
} else {
|
} else {
|
||||||
return NSAPI_ERROR_NO_MEMORY;
|
return NSAPI_ERROR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||||
if (password && (len = strlen(password)) > 0) {
|
if (password && (len = strlen(password)) > 0) {
|
||||||
_pwd = (char*)malloc(len*sizeof(char)+1);
|
_pwd = (char*)malloc(len*sizeof(char)+1);
|
||||||
if (_pwd) {
|
if (_pwd) {
|
||||||
memcpy(_pwd, password, len);
|
memcpy(_pwd, password, len+1);
|
||||||
} else {
|
} else {
|
||||||
return NSAPI_ERROR_NO_MEMORY;
|
return NSAPI_ERROR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ bool AT_CellularNetwork::get_context(nsapi_ip_stack_t requested_stack)
|
||||||
if (apn_len > 0 && !_apn) {
|
if (apn_len > 0 && !_apn) {
|
||||||
_apn = (char*)malloc(apn_len*sizeof(char)+1);
|
_apn = (char*)malloc(apn_len*sizeof(char)+1);
|
||||||
if (_apn) {
|
if (_apn) {
|
||||||
memcpy(_apn, apn, apn_len);
|
memcpy(_apn, apn, apn_len+1);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue