diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-01-27 13:56:44 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-01-27 13:59:05 -0600 |
commit | 5e94e2bad84d232ced58f54b52999277ef198048 (patch) | |
tree | 8df2e620ec5a096440433b14fe4409f009056dd8 /drivers/stemodem | |
parent | dda8b972ba9e86e5d0e8dd0a441a1c1f2afd9cbe (diff) | |
download | ofono-5e94e2bad84d232ced58f54b52999277ef198048.tar.bz2 |
Fix: Remove username/password elements
The reason for this is twofold. First the current code actually leaks
memory since it uses g_strdup on username/password and never frees it
anywhere. Second the username/password command can just be sent inside
activate_primary, no reason to do it in the callback.
The fix removes the username / password structure members and moves the
AT*EIAAUW handling to activate_primary. This is almost exactly like the
username / password / context definition for MBM modems.
Diffstat (limited to 'drivers/stemodem')
-rw-r--r-- | drivers/stemodem/gprs-context.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c index 6cc7de7e..0fbbbb14 100644 --- a/drivers/stemodem/gprs-context.c +++ b/drivers/stemodem/gprs-context.c @@ -62,8 +62,6 @@ static GSList *g_caif_devices; struct gprs_context_data { GAtChat *chat; unsigned int active_context; - char *username; - char *password; }; struct conn_info { @@ -368,8 +366,8 @@ static void ste_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data) struct ofono_gprs_context *gc = cbd->user; struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); struct cb_data *ncbd = NULL; + char buf[128]; struct conn_info *conn; - char buf[AUTH_BUF_LENGTH]; GSList *l; dump_response("cgdcont_cb", ok, result); @@ -384,14 +382,6 @@ static void ste_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data) return; } - /* Set username and password */ - sprintf(buf, "AT*EIAAUW=%d,1,\"%s\",\"%s\"", gcd->active_context, - gcd->username, gcd->password); - - if (g_at_chat_send(gcd->chat, buf, none_prefix, - NULL, NULL, NULL) == 0) - goto error; - ncbd = g_memdup(cbd, sizeof(struct cb_data)); l = g_slist_find_custom(g_caif_devices, GUINT_TO_POINTER(0), @@ -409,6 +399,7 @@ static void ste_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data) if (g_at_chat_send(gcd->chat, buf, NULL, ste_eppsd_up_cb, ncbd, g_free) > 0) return; + error: if (ncbd) g_free(ncbd); @@ -425,17 +416,22 @@ static void ste_gprs_activate_primary(struct ofono_gprs_context *gc, { struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); struct cb_data *cbd = cb_data_new(cb, data); - char buf[OFONO_GPRS_MAX_APN_LENGTH + 128]; + char buf[AUTH_BUF_LENGTH]; int len; if (!cbd) goto error; gcd->active_context = ctx->cid; - gcd->username = g_strdup(ctx->username); - gcd->password = g_strdup(ctx->password); cbd->user = gc; + /* Set username and password */ + sprintf(buf, "AT*EIAAUW=%d,1,\"%s\",\"%s\"", ctx->cid, + ctx->username, ctx->password); + + if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0) + goto error; + len = sprintf(buf, "AT+CGDCONT=%u,\"IP\"", ctx->cid); if (ctx->apn) |