Skip to content

Commit 0c49b66

Browse files
Teppo JärvelinAri Parkkila
authored andcommitted
Fixed bug when copying apn, username and password.
1 parent 9016ed5 commit 0c49b66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
8080
if (apn && (len = strlen(apn)) > 0) {
8181
_apn = (char*)malloc(len*sizeof(char)+1);
8282
if (_apn) {
83-
memcpy(_apn, apn, len);
83+
memcpy(_apn, apn, len+1);
8484
} else {
8585
return NSAPI_ERROR_NO_MEMORY;
8686
}
@@ -89,7 +89,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
8989
if (username && (len = strlen(username)) > 0) {
9090
_uname = (char*)malloc(len*sizeof(char)+1);
9191
if (_uname) {
92-
memcpy(_uname, username, len);
92+
memcpy(_uname, username, len+1);
9393
} else {
9494
return NSAPI_ERROR_NO_MEMORY;
9595
}
@@ -98,7 +98,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
9898
if (password && (len = strlen(password)) > 0) {
9999
_pwd = (char*)malloc(len*sizeof(char)+1);
100100
if (_pwd) {
101-
memcpy(_pwd, password, len);
101+
memcpy(_pwd, password, len+1);
102102
} else {
103103
return NSAPI_ERROR_NO_MEMORY;
104104
}
@@ -433,7 +433,7 @@ bool AT_CellularNetwork::get_context(nsapi_ip_stack_t requested_stack)
433433
if (apn_len > 0 && !_apn) {
434434
_apn = (char*)malloc(apn_len*sizeof(char)+1);
435435
if (_apn) {
436-
memcpy(_apn, apn, apn_len);
436+
memcpy(_apn, apn, apn_len+1);
437437
} else {
438438
return false;
439439
}

0 commit comments

Comments
 (0)