Merge "Move sprintf to snprintf."

This commit is contained in:
Yabin Cui 2015-02-18 20:26:02 +00:00 committed by Gerrit Code Review
commit b703214e25
5 changed files with 10 additions and 12 deletions

View file

@ -317,9 +317,7 @@ static int load_verity_table(struct dm_ioctl *io, char *name, char *blockdev, in
// build the verity params here
verity_params = buffer + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
if (sprintf(verity_params, "%s", table) < 0) {
return -1;
}
strcpy(verity_params, table);
// set next target boundary
verity_params += strlen(verity_params) + 1;

View file

@ -389,7 +389,7 @@ int do_mount(int nargs, char **args)
return -1;
}
sprintf(tmp, "/dev/block/mtdblock%d", n);
snprintf(tmp, sizeof(tmp), "/dev/block/mtdblock%d", n);
if (wait)
wait_for_file(tmp, COMMAND_RETRY_TIMEOUT);
@ -409,7 +409,7 @@ int do_mount(int nargs, char **args)
}
for (n = 0; ; n++) {
sprintf(tmp, "/dev/block/loop%d", n);
snprintf(tmp, sizeof(tmp), "/dev/block/loop%d", n);
loop = open(tmp, mode | O_CLOEXEC);
if (loop < 0) {
close(fd);

View file

@ -152,7 +152,7 @@ void fixup_sys_perms(const char *upath)
if ((strlen(upath) + strlen(dp->attr) + 6) > sizeof(buf))
break;
sprintf(buf,"/sys%s/%s", upath, dp->attr);
snprintf(buf, sizeof(buf), "/sys%s/%s", upath, dp->attr);
INFO("fixup %s %d %d 0%o\n", buf, dp->uid, dp->gid, dp->perm);
chown(buf, dp->uid, dp->gid);
chmod(buf, dp->perm);

View file

@ -252,7 +252,7 @@ void service_start(struct service *svc, const char *dynamic_args)
umask(077);
if (properties_inited()) {
get_property_workspace(&fd, &sz);
sprintf(tmp, "%d,%d", dup(fd), sz);
snprintf(tmp, sizeof(tmp), "%d,%d", dup(fd), sz);
add_environment("ANDROID_PROPERTY_WORKSPACE", tmp);
}

View file

@ -236,13 +236,13 @@ int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info)
#if VERBOSE
static void hex2str(char *buf, const unsigned char *array, int len)
static void hex2str(char *buf, size_t buf_size, const unsigned char *array, int len)
{
int i;
char *cp = buf;
char *buf_end = buf + buf_size;
for (i = 0; i < len; i++) {
cp += sprintf(cp, " %02x ", array[i]);
cp += snprintf(cp, buf_end - cp, " %02x ", array[i]);
}
}
@ -278,7 +278,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
ALOGD("giaddr = %s", ipaddr(msg->giaddr));
c = msg->hlen > 16 ? 16 : msg->hlen;
hex2str(buf, msg->chaddr, c);
hex2str(buf, sizeof(buf), msg->chaddr, c);
ALOGD("chaddr = {%s}", buf);
for (n = 0; n < 64; n++) {
@ -327,7 +327,7 @@ void dump_dhcp_msg(dhcp_msg *msg, int len)
memcpy(buf, &x[2], n);
buf[n] = '\0';
} else {
hex2str(buf, &x[2], optsz);
hex2str(buf, sizeof(buf), &x[2], optsz);
}
if (x[0] == OPT_MESSAGE_TYPE)
name = dhcp_type_to_name(x[2]);