mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Fix potential un-terminated buffer problem (CWE-120)
This commit is contained in:
parent
3437d5fcb4
commit
2e288e74ab
|
@ -41,7 +41,9 @@ ImagingHistogramNew(Imaging im)
|
||||||
|
|
||||||
/* Create histogram descriptor */
|
/* Create histogram descriptor */
|
||||||
h = calloc(1, sizeof(struct ImagingHistogramInstance));
|
h = calloc(1, sizeof(struct ImagingHistogramInstance));
|
||||||
strncpy(h->mode, im->mode, IMAGING_MODE_LENGTH);
|
strncpy(h->mode, im->mode, IMAGING_MODE_LENGTH-1);
|
||||||
|
h->mode[IMAGING_MODE_LENGTH-1] = 0;
|
||||||
|
|
||||||
h->bands = im->bands;
|
h->bands = im->bands;
|
||||||
h->histogram = calloc(im->pixelsize, 256 * sizeof(long));
|
h->histogram = calloc(im->pixelsize, 256 * sizeof(long));
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ ImagingPaletteNew(const char* mode)
|
||||||
if (!palette)
|
if (!palette)
|
||||||
return (ImagingPalette) ImagingError_MemoryError();
|
return (ImagingPalette) ImagingError_MemoryError();
|
||||||
|
|
||||||
strncpy(palette->mode, mode, IMAGING_MODE_LENGTH);
|
strncpy(palette->mode, mode, IMAGING_MODE_LENGTH-1);
|
||||||
|
palette->mode[IMAGING_MODE_LENGTH-1] = 0;
|
||||||
|
|
||||||
/* Initialize to ramp */
|
/* Initialize to ramp */
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user