Skip to content

Commit 9016ed5

Browse files
Teppo JärvelinAri Parkkila
authored andcommitted
Don't allow zero length apn, password or username.
1 parent 1a3b6e5 commit 9016ed5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
7777
const char *username, const char *password)
7878
{
7979
size_t len;
80-
if (apn) {
81-
len = strlen(apn);
80+
if (apn && (len = strlen(apn)) > 0) {
8281
_apn = (char*)malloc(len*sizeof(char)+1);
8382
if (_apn) {
8483
memcpy(_apn, apn, len);
@@ -87,8 +86,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
8786
}
8887
}
8988

90-
if (username) {
91-
len = strlen(username);
89+
if (username && (len = strlen(username)) > 0) {
9290
_uname = (char*)malloc(len*sizeof(char)+1);
9391
if (_uname) {
9492
memcpy(_uname, username, len);
@@ -97,8 +95,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
9795
}
9896
}
9997

100-
if (password) {
101-
len = strlen(password);
98+
if (password && (len = strlen(password)) > 0) {
10299
_pwd = (char*)malloc(len*sizeof(char)+1);
103100
if (_pwd) {
104101
memcpy(_pwd, password, len);

0 commit comments

Comments
 (0)