Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b703214e authored by Yabin Cui's avatar Yabin Cui Committed by Gerrit Code Review
Browse files

Merge "Move sprintf to snprintf."

parents 1ac334ec e2d63af0
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
        }

+5 −5
Original line number Diff line number Diff line
@@ -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]);