Mageia Bugzilla – Attachment 8514 Details for
Bug 19481
libgd new security issue CVE-2016-7568
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Simple test of libgd
gdex.c (text/plain), 1.44 KB, created by
Len Lawrence
on 2016-10-12 00:19:19 CEST
(
hide
)
Description:
Simple test of libgd
Filename:
MIME Type:
Creator:
Len Lawrence
Created:
2016-10-12 00:19:19 CEST
Size:
1.44 KB
patch
obsolete
>/* Linking: */ >// gcc -lgd -lpng -lz -ljpeg -lfreetype -lm <program> > >/* Bring in gd library functions */ >#include "gd.h" > >/* Bring in standard I/O so we can output the PNG to a file */ >#include <stdio.h> > >int main() { > /* Declare the image */ > gdImagePtr im; > /* Declare output files */ > FILE *pngout, *jpegout; > /* Declare color indexes */ > int black; > int white; > > /* Allocate the image: 64 pixels across by 64 pixels tall */ > im = gdImageCreate(64, 64); > > /* Allocate the color black (red, green and blue all minimum). > Since this is the first color in a new image, it will > be the background color. */ > black = gdImageColorAllocate(im, 0, 0, 0); > > /* Allocate the color white (red, green and blue all maximum). */ > white = gdImageColorAllocate(im, 255, 255, 255); > > /* Draw a line from the upper left to the lower right, > using white color index. */ > gdImageLine(im, 0, 0, 63, 63, white); > > /* Open a file for writing. "wb" means "write binary", important > under MSDOS, harmless under Unix. */ > pngout = fopen("test.png", "wb"); > > /* Do the same for a JPEG-format file. */ > jpegout = fopen("test.jpg", "wb"); > > /* Output the image to the disk file in PNG format. */ > gdImagePng(im, pngout); > > /* Output the same image in JPEG format, using the default > JPEG quality setting. */ > gdImageJpeg(im, jpegout, -1); > > /* Close the files. */ > fclose(pngout); > fclose(jpegout); > > /* Destroy the image in memory. */ > gdImageDestroy(im); >} >
/* Linking: */ // gcc -lgd -lpng -lz -ljpeg -lfreetype -lm <program> /* Bring in gd library functions */ #include "gd.h" /* Bring in standard I/O so we can output the PNG to a file */ #include <stdio.h> int main() { /* Declare the image */ gdImagePtr im; /* Declare output files */ FILE *pngout, *jpegout; /* Declare color indexes */ int black; int white; /* Allocate the image: 64 pixels across by 64 pixels tall */ im = gdImageCreate(64, 64); /* Allocate the color black (red, green and blue all minimum). Since this is the first color in a new image, it will be the background color. */ black = gdImageColorAllocate(im, 0, 0, 0); /* Allocate the color white (red, green and blue all maximum). */ white = gdImageColorAllocate(im, 255, 255, 255); /* Draw a line from the upper left to the lower right, using white color index. */ gdImageLine(im, 0, 0, 63, 63, white); /* Open a file for writing. "wb" means "write binary", important under MSDOS, harmless under Unix. */ pngout = fopen("test.png", "wb"); /* Do the same for a JPEG-format file. */ jpegout = fopen("test.jpg", "wb"); /* Output the image to the disk file in PNG format. */ gdImagePng(im, pngout); /* Output the same image in JPEG format, using the default JPEG quality setting. */ gdImageJpeg(im, jpegout, -1); /* Close the files. */ fclose(pngout); fclose(jpegout); /* Destroy the image in memory. */ gdImageDestroy(im); }
View Attachment As Raw
Actions:
View
Attachments on
bug 19481
: 8514 |
8515