@@ -80,7 +80,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
80
80
if (apn && (len = strlen (apn)) > 0 ) {
81
81
_apn = (char *)malloc (len*sizeof (char )+1 );
82
82
if (_apn) {
83
- memcpy (_apn, apn, len);
83
+ memcpy (_apn, apn, len+ 1 );
84
84
} else {
85
85
return NSAPI_ERROR_NO_MEMORY;
86
86
}
@@ -89,7 +89,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
89
89
if (username && (len = strlen (username)) > 0 ) {
90
90
_uname = (char *)malloc (len*sizeof (char )+1 );
91
91
if (_uname) {
92
- memcpy (_uname, username, len);
92
+ memcpy (_uname, username, len+ 1 );
93
93
} else {
94
94
return NSAPI_ERROR_NO_MEMORY;
95
95
}
@@ -98,7 +98,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
98
98
if (password && (len = strlen (password)) > 0 ) {
99
99
_pwd = (char *)malloc (len*sizeof (char )+1 );
100
100
if (_pwd) {
101
- memcpy (_pwd, password, len);
101
+ memcpy (_pwd, password, len+ 1 );
102
102
} else {
103
103
return NSAPI_ERROR_NO_MEMORY;
104
104
}
@@ -433,7 +433,7 @@ bool AT_CellularNetwork::get_context(nsapi_ip_stack_t requested_stack)
433
433
if (apn_len > 0 && !_apn) {
434
434
_apn = (char *)malloc (apn_len*sizeof (char )+1 );
435
435
if (_apn) {
436
- memcpy (_apn, apn, apn_len);
436
+ memcpy (_apn, apn, apn_len+ 1 );
437
437
} else {
438
438
return false ;
439
439
}
0 commit comments