$OpenBSD: patch-musicin_c,v 1.2 2003/04/20 22:40:14 naddy Exp $ --- musicin.c.orig Wed Jan 22 10:43:17 1997 +++ musicin.c Mon Apr 21 00:32: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 : "); - 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: ()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: ()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/): "); - 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/): "); - 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/): "); - 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/): "); - 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/): "); - gets(t); + fgets(t, sizeof t,stdin); + t[strlen(t) - 1] = NULL_CHAR; if (*t == 'y' || *t == 'Y') exit(0); } @@ -708,7 +722,7 @@ void print_config( frame_params *fr_ps, int frameNum=0; -void main(argc, argv) +int main(argc, argv) int argc; char **argv; {