sammycage / plutosvg Goto Github PK
View Code? Open in Web Editor NEWTiny SVG rendering library in C
License: MIT License
Tiny SVG rendering library in C
License: MIT License
no install command cmake scripts, could add it?
I am developing the canvas js API based on plutovg and quickjs.
Path2D can receive SVG path. So I want this library to implement it.
Reference: https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D/Path2D
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var p = new Path2D("M10 10 h 80 v 80 h -80 Z");
ctx.fill(p);
Can we export parse_path function? It could be like the below.
plutovg_path_t *plutosvg_parse_path(const char *path, size_t len)
Thanks,
Yu Zhu
An integer overflow in the allocated size of calloc
causes a segment fault.
It might lead to heap overflow and arbitrary code execution.
code:
#include <plutosvg.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
plutovg_surface_t* surface = plutosvg_load_from_file(argv[1], NULL, 0, 0, 96.0);
return 0;
}
run
$ ./example ./poc
Segmentation fault
ASAN report
==16700==WARNING: AddressSanitizer failed to allocate 0xfffffffffef21b74 bytes
==16700==AddressSanitizer's allocator is terminating the process instead of returning 0
==16700==If you don't like this behavior set allocator_may_return_null=1
==16700==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_allocator.cc:218 "((0)) != (0)" (0x0, 0x0)
#0 0x7ffff6f01bf2 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe9bf2)
#1 0x7ffff6f20575 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x108575)
#2 0x7ffff6f07332 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xef332)
#3 0x7ffff6e3fe46 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x27e46)
#4 0x7ffff6ef6b0a in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb0a)
#5 0x555555588ba1 in plutovg_surface_create (/home/waterfire/fuzz/example/plutosvg/build/example/example+0x34ba1)
#6 0x55555557a6aa in plutosvg_load_from_memory (/home/waterfire/fuzz/example/plutosvg/build/example/example+0x266aa)
#7 0x55555557aa21 in plutosvg_load_from_file (/home/waterfire/fuzz/example/plutosvg/build/example/example+0x26a21)
#8 0x55555556405a in main (/home/waterfire/fuzz/example/plutosvg/build/example/example+0x1005a)
#9 0x7ffff66aac86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
#10 0x555555563f19 in _start (/home/waterfire/fuzz/example/plutosvg/build/example/example+0xff19)
plutosvg_load_from_memory
does not check the size of width
and height
and calls plutovg_surface_create(width, height);
.
In plutovg_surface_create:
plutovg_surface_t* plutovg_surface_create(int width, int height)
{
plutovg_surface_t* surface = malloc(sizeof(plutovg_surface_t));
surface->ref = 1;
surface->owndata = 1;
surface->data = calloc(1, (size_t)(width * height * 4));
surface->width = width;
surface->height = height;
surface->stride = width * 4;
return surface;
}
An integer overflow might happen when calculating width * height * 4
. It might be better to check the sizes of width
and height
before the allocation.
I git cloned the project. Doesn't work
git cloned the sister plutovg and combined all files into a single folder. Still doesn't work.
Could you make an animated GIF showing this working on Windows or Linux? A simple proof of concept.
Why does it require a version that doesn't exist yet?
cmake_minimum_required(VERSION 3.3)
And then following the instruction I get the message...
CMake Error at CMakeLists.txt:14 (add_subdirectory):
The source directory does not contain a CMakeLists.txt file.
Hello @sammycage,
I found this alert during the compile
declaration of "id" hides function parameter
Line 520 in 336c029
declaration of 'value' hides previous local declaration
Line 1212 in 336c029
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.