diff --git a/libImaging/Histo.c b/libImaging/Histo.c index 513c84475..0bfc8dfe9 100644 --- a/libImaging/Histo.c +++ b/libImaging/Histo.c @@ -41,7 +41,7 @@ ImagingHistogramNew(Imaging im) /* Create histogram descriptor */ h = calloc(1, sizeof(struct ImagingHistogramInstance)); - strcpy(h->mode, im->mode); + strncpy(h->mode, im->mode, IMAGING_MODE_LENGTH); h->bands = im->bands; h->histogram = calloc(im->pixelsize, 256 * sizeof(long)); diff --git a/libImaging/Imaging.h b/libImaging/Imaging.h index dd9532389..cf94dae0b 100644 --- a/libImaging/Imaging.h +++ b/libImaging/Imaging.h @@ -141,7 +141,7 @@ struct ImagingHistogramInstance { struct ImagingPaletteInstance { /* Format */ - char mode[4+1]; /* Band names */ + char mode[IMAGING_MODE_LENGTH]; /* Band names */ /* Data */ UINT8 palette[1024];/* Palette data (same format as image data) */ diff --git a/libImaging/Palette.c b/libImaging/Palette.c index bd4f4f1d6..9b0dd57c4 100644 --- a/libImaging/Palette.c +++ b/libImaging/Palette.c @@ -37,7 +37,7 @@ ImagingPaletteNew(const char* mode) if (!palette) return (ImagingPalette) ImagingError_MemoryError(); - strcpy(palette->mode, mode); + strncpy(palette->mode, mode, IMAGING_MODE_LENGTH); /* Initialize to ramp */ for (i = 0; i < 256; i++) {