- fix a set of buffer overflows in fgets into a wrong sized buffer

- use update-patches
- bump PKGNAME to p1
This commit is contained in:
avsm 2003-04-14 09:39:18 +00:00
parent ff3f5e6565
commit 6bb79aa158
6 changed files with 167 additions and 11 deletions

View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.16 2002/12/23 00:37:49 pvalchev Exp $
# $OpenBSD: Makefile,v 1.17 2003/04/14 09:39:18 avsm Exp $
COMMENT= "MPEG layer I, II and III audio file encoder"
DISTNAME= dist10
PKGNAME= mp3encode-1.10
PKGNAME= mp3encode-1.10p1
CATEGORIES= audio
MASTER_SITES= ftp://ftp.sunet.se/pub/multimedia/Berkeley/mpeg2/conformance-bitstreams/audio/mpeg2/software/technical_report/

View File

@ -1,5 +1,6 @@
--- Makefile.in.orig Wed Jan 22 04:43:12 1997
+++ Makefile.in Thu Jan 27 00:49:39 2000
$OpenBSD: patch-Makefile_in,v 1.1 2003/04/14 09:39:18 avsm Exp $
--- Makefile.in.orig Wed Jan 22 09:43:12 1997
+++ Makefile.in Mon Apr 14 10:24:38 2003
@@ -16,7 +16,7 @@
## Received from Mike Coleman
############################################################################
@ -9,7 +10,7 @@
c_sources = \
common.c \
@@ -40,7 +40,8 @@
@@ -40,7 +40,8 @@ DEP = $(c_sources:.c=.d)
NINT_SWITCH = @NINTSW@
@ -19,7 +20,7 @@
PGM = encode
@@ -48,11 +49,12 @@
@@ -48,11 +49,12 @@ LIBS = @LIBS@ @MATHLIBS@
%.o: %.c

View File

@ -1,11 +1,12 @@
--- common.h.orig Wed Jan 22 04:43:13 1997
+++ common.h Thu Jan 27 00:46:53 2000
$OpenBSD: patch-common_h,v 1.1 2003/04/14 09:39:18 avsm Exp $
--- common.h.orig Wed Jan 22 09:43:13 1997
+++ common.h Mon Apr 14 10:24:38 2003
@@ -93,7 +93,7 @@
#endif
#ifdef UNIX
-#define TABLES_PATH "tables" /* to find data files */
+#define TABLES_PATH "ZAP" /* to find data files */
+#define TABLES_PATH "/usr/local/lib/mp3encode" /* to find data files */
/* name of environment variable holding path of table files */
#define MPEGTABENV "MPEGTABLES"
#define PATH_SEPARATOR "/" /* how to build paths */

View File

@ -1,5 +1,6 @@
--- encoder.h.orig Wed Jan 22 04:43:14 1997
+++ encoder.h Thu Jan 27 00:31:35 2000
$OpenBSD: patch-encoder_h,v 1.1 2003/04/14 09:39:18 avsm Exp $
--- encoder.h.orig Wed Jan 22 09:43:14 1997
+++ encoder.h Mon Apr 14 10:24:38 2003
@@ -62,7 +62,7 @@
#define DFLT_LAY 2 /* default encoding layer is II */

View File

@ -0,0 +1,141 @@
--- musicin.c.orig Wed Jan 22 09:43:17 1997
+++ musicin.c Mon Apr 14 10:35:17 2003
@@ -151,7 +151,7 @@ char encoded_file_name[MAX_NA
int j;
long int freq;
int model, brt;
- char t[50];
+ char t[255];
IFF_AIFF pcm_aiff_data;
layer *info = fr_ps->header;
long soundPosition;
@@ -161,7 +161,8 @@ char encoded_file_name[MAX_NA
do {
printf("Enter PCM input file name <required>: ");
- gets(original_file_name);
+ fgets(original_file_name, sizeof original_file_name,stdin);
+ original_file_name[strlen(original_file_name) - 1] = NULL_CHAR;
if (original_file_name[0] == NULL_CHAR)
printf("PCM input file name is required.\n");
} while (original_file_name[0] == NULL_CHAR);
@@ -182,8 +183,9 @@ char encoded_file_name[MAX_NA
original_file_name, DFLT_EXT);
#endif
- gets(encoded_file_name);
-
+ fgets(encoded_file_name, sizeof t,stdin);
+ encoded_file_name[strlen(encoded_file_name) - 1] = NULL_CHAR;
+
if (encoded_file_name[0] == NULL_CHAR) {
#ifdef MS_DOS
strcpy(encoded_file_name, temp_str);
@@ -227,7 +229,8 @@ char encoded_file_name[MAX_NA
else { /* Not using Audio IFF sound file headers. */
printf("What is the sampling frequency? <44100>[Hz]: ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
freq = atol(t);
switch (freq) {
case 48000 : info->sampling_frequency = 1;
@@ -268,7 +271,8 @@ char encoded_file_name[MAX_NA
printf("Which layer do you want to use?\n");
printf("Available: Layer (1), Layer (<2>), Layer (3): ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
switch(*t){
case '1': info->lay = 1; printf(">>> Using Layer %s\n",t); break;
case '2': info->lay = 2; printf(">>> Using Layer %s\n",t); break;
@@ -279,7 +283,8 @@ char encoded_file_name[MAX_NA
printf("Which mode do you want?\n");
printf("Available: (<s>)tereo, (j)oint stereo, ");
printf("(d)ual channel, s(i)ngle Channel: ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
switch(*t){
case 's':
case 'S':
@@ -308,7 +313,8 @@ char encoded_file_name[MAX_NA
}
printf("Which psychoacoustic model do you want to use? <1>: ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
model = atoi(t);
if (model > 2 || model < 1) {
printf(">>> Default model 1 selected\n");
@@ -322,7 +328,8 @@ char encoded_file_name[MAX_NA
/* set default bitrate to highest allowed, which is index 14 */
brt = bitrate[info->version][info->lay-1][14];
printf( "What is the total bitrate? <%u>[kbps]: ", brt );
- gets( t );
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
brt = atoi( t );
if ( brt == 0 )
j = 15;
@@ -348,7 +355,8 @@ char encoded_file_name[MAX_NA
printf("What type of de-emphasis should the decoder use?\n");
printf("Available: (<n>)one, (5)0/15 microseconds, (c)citt j.17: ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
if (*t != 'n' && *t != '5' && *t != 'c') {
printf(">>> Using default no de-emphasis\n");
info->emphasis = 0;
@@ -363,7 +371,8 @@ char encoded_file_name[MAX_NA
/* Start 2. Part changes for CD Ver 3.2; jsp; 22-Aug-1991 */
printf("Do you want to set the private bit? (y/<n>): ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
if (*t == 'y' || *t == 'Y') info->extension = 1;
else info->extension = 0;
if(info->extension) printf(">>> Private bit set\n");
@@ -372,28 +381,33 @@ char encoded_file_name[MAX_NA
/* End changes for CD Ver 3.2; jsp; 22-Aug-1991 */
printf("Do you want error protection? (y/<n>): ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+
+ t[strlen(t) - 1] = NULL_CHAR;
if (*t == 'y' || *t == 'Y') info->error_protection = TRUE;
else info->error_protection = FALSE;
if(info->error_protection) printf(">>> Error protection used\n");
else printf(">>> Error protection not used\n");
printf("Is the material copyrighted? (y/<n>): ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
if (*t == 'y' || *t == 'Y') info->copyright = 1;
else info->copyright = 0;
if(info->copyright) printf(">>> Copyrighted material\n");
else printf(">>> Material not copyrighted\n");
printf("Is this the original? (y/<n>): ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
if (*t == 'y' || *t == 'Y') info->original = 1;
else info->original = 0;
if(info->original) printf(">>> Original material\n");
else printf(">>> Material not original\n");
printf("Do you wish to exit (last chance before encoding)? (y/<n>): ");
- gets(t);
+ fgets(t, sizeof t,stdin);
+ t[strlen(t) - 1] = NULL_CHAR;
if (*t == 'y' || *t == 'Y') exit(0);
}

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-psy_c,v 1.1 2003/04/14 09:39:18 avsm Exp $
--- psy.c.orig Mon Apr 14 10:26:05 2003
+++ psy.c Mon Apr 14 10:26:37 2003
@@ -439,7 +439,7 @@ int table;
printf("Please check %s table\n", ta);
exit(1);
}
- fgets(t, 150, fp);
+ fgets(t, sizeof t, fp);
sscanf(t, "table %ld", &index);
if(index != table){
printf("error in absthr table %s",ta);