Revision 363a37d5 block-vmdk.c

b/block-vmdk.c
153 153
        return -1;
154 154

  
155 155
    tmp_str = strstr(desc,"parentCID");
156
    strcpy(tmp_desc, tmp_str);
156
    pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);
157 157
    if ((p_name = strstr(desc,"CID")) != 0) {
158 158
        p_name += sizeof("CID");
159
        sprintf(p_name,"%x\n",cid);
160
        strcat(desc,tmp_desc);
159
        snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);
160
        pstrcat(desc, sizeof(desc), tmp_desc);
161 161
    }
162 162

  
163 163
    if (bdrv_pwrite(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
......
252 252
    if ((temp_str = strrchr(real_filename, ':')) != NULL)
253 253
        real_filename = temp_str + 1;
254 254

  
255
    sprintf(s_desc, desc_template, p_cid, p_cid, backing_file
256
            , (uint32_t)header.capacity, real_filename);
255
    snprintf(s_desc, sizeof(s_desc), desc_template, p_cid, p_cid, backing_file,
256
             (uint32_t)header.capacity, real_filename);
257 257

  
258 258
    /* write the descriptor */
259 259
    if (lseek(snp_fd, 0x200, SEEK_SET) == -1)
......
349 349
            path_combine(parent_img_name, sizeof(parent_img_name),
350 350
                         filename, s->hd->backing_file);
351 351
        } else {
352
            strcpy(parent_img_name, s->hd->backing_file);
352
            pstrcpy(parent_img_name, sizeof(parent_img_name),
353
                    s->hd->backing_file);
353 354
        }
354 355

  
355 356
        s->hd->backing_hd = bdrv_new("");
......
790 791
        real_filename = temp_str + 1;
791 792
    if ((temp_str = strrchr(real_filename, ':')) != NULL)
792 793
        real_filename = temp_str + 1;
793
    sprintf(desc, desc_template, time(NULL), (unsigned long)total_size,
794
            real_filename, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (63 * 16));
794
    snprintf(desc, sizeof(desc), desc_template, time(NULL), (unsigned long)total_size,
795
             real_filename, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (63 * 16));
795 796

  
796 797
    /* write the descriptor */
797 798
    lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);

Also available in: Unified diff