From: hackbard Date: Sun, 20 Apr 2003 21:51:19 +0000 (+0000) Subject: buf terminated X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=37897edda2f9484f7257e76cdc3459bc6ec2f7bc;p=my-code%2Fmp3db.git buf terminated --- diff --git a/mp3read.c b/mp3read.c index 4bfc290..1e2a296 100644 --- a/mp3read.c +++ b/mp3read.c @@ -33,6 +33,8 @@ int main (int argc,char **argv) unsigned char buf[MAX_BUF_SIZE]; char filename[MAX_FILENAME]; + memset(buf,0,sizeof(buf)); + strcpy(filename,argv[1]); file_size=atoi(argv[2]); @@ -57,12 +59,15 @@ int main (int argc,char **argv) } read(file_fd,&buf,MAX_TITLE); + buf[MAX_TITLE-1]=0; printf("title: %s
\n",buf); read(file_fd,&buf,MAX_ARTIST); + buf[MAX_ARTIST-1]=0; printf("artist: %s
\n",buf); read(file_fd,&buf,MAX_ALBUM); + buf[MAX_ALBUM-1]=0; printf("album: %s
\n",buf); // read(file_fd,&buf,MAX_YEAR);