Fix: Use snprintf instead of sprintf in stemodem

This commit is contained in:
Denis Kenzior 2010-02-05 12:01:13 -06:00
parent d223243913
commit ced9692361
2 changed files with 11 additions and 10 deletions

View File

@ -394,7 +394,8 @@ static void ste_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
conn = l->data;
conn->cid = gcd->active_context;
sprintf(buf, "AT*EPPSD=1,%u,%u", conn->channel_id, conn->cid);
snprintf(buf, sizeof(buf), "AT*EPPSD=1,%u,%u",
conn->channel_id, conn->cid);
if (g_at_chat_send(gcd->chat, buf, NULL,
ste_eppsd_up_cb, ncbd, g_free) > 0)
@ -426,13 +427,13 @@ static void ste_gprs_activate_primary(struct ofono_gprs_context *gc,
cbd->user = gc;
/* Set username and password */
sprintf(buf, "AT*EIAAUW=%d,1,\"%s\",\"%s\"", ctx->cid,
ctx->username, ctx->password);
snprintf(buf, sizeof(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);
len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"", ctx->cid);
if (ctx->apn)
snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
@ -476,7 +477,7 @@ static void ste_gprs_deactivate_primary(struct ofono_gprs_context *gc,
conn = l->data;
sprintf(buf, "AT*EPPSD=0,%u,%u", conn->channel_id, id);
snprintf(buf, sizeof(buf), "AT*EPPSD=0,%u,%u", conn->channel_id, id);
if (g_at_chat_send(gcd->chat, buf, none_prefix,
ste_eppsd_down_cb, cbd, g_free) > 0)

View File

@ -196,9 +196,9 @@ static void ste_dial(struct ofono_voicecall *vc,
cbd->user = vc;
if (ph->type == 145)
sprintf(buf, "ATD+%s", ph->number);
snprintf(buf, sizeof(buf), "ATD+%s", ph->number);
else
sprintf(buf, "ATD%s", ph->number);
snprintf(buf, sizeof(buf), "ATD%s", ph->number);
switch (clir) {
case OFONO_CLIR_OPTION_INVOCATION:
@ -312,7 +312,7 @@ static void ste_release_specific(struct ofono_voicecall *vc, int id,
req->data = data;
req->id = id;
sprintf(buf, "AT+CHLD=1%d", id);
snprintf(buf, sizeof(buf), "AT+CHLD=1%d", id);
if (g_at_chat_send(vd->chat, buf, none_prefix,
release_id_cb, req, g_free) > 0)
@ -330,7 +330,7 @@ static void ste_private_chat(struct ofono_voicecall *vc, int id,
{
char buf[32];
sprintf(buf, "AT+CHLD=2%d", id);
snprintf(buf, sizeof(buf), "AT+CHLD=2%d", id);
ste_template(buf, vc, ste_generic_cb, 0, cb, data);
}
@ -362,7 +362,7 @@ static void ste_deflect(struct ofono_voicecall *vc,
char buf[128];
unsigned int incoming_or_waiting = (0x1 << 4) | (0x1 << 5);
sprintf(buf, "AT+CTFR=\"%s\",%d", ph->number, ph->type);
snprintf(buf, sizeof(buf), "AT+CTFR=\"%s\",%d", ph->number, ph->type);
ste_template(buf, vc, ste_generic_cb, incoming_or_waiting, cb, data);
}