Skip to content

Commit b6f233e

Browse files
eivindj-nordicrlubos
authored andcommitted
lib: pdn: return error on pdn_ctx_configure if apn is too large
Return error when pdn_ctx_configure is called with a large (faulty) apn to avoid unnecessary processing and consumption of memory. Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 1949b61 commit b6f233e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/pdn/pdn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ LOG_MODULE_REGISTER(pdn, CONFIG_PDN_LOG_LEVEL);
2424
#define PDN_ACT_REASON_IPV4_ONLY (0)
2525
#define PDN_ACT_REASON_IPV6_ONLY (1)
2626

27+
#define APN_STR_MAX_LEN 64
28+
2729
struct pdn {
2830
pdn_event_handler_t callback;
2931
int8_t context_id;
@@ -249,6 +251,10 @@ int pdn_ctx_configure(uint8_t cid, const char *apn, enum pdn_fam fam,
249251
return -EFAULT;
250252
}
251253

254+
if (strlen(apn) >= APN_STR_MAX_LEN) {
255+
return -EINVAL;
256+
}
257+
252258
switch (fam) {
253259
case PDN_FAM_IPV4:
254260
strncpy(family, "IP", sizeof(family));

0 commit comments

Comments
 (0)