Fix buffer overrun and non terminated string problem.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4651 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Björn Groenvall
1998-03-22 11:34:54 +00:00
parent acd0fe881c
commit 490fbda2df

View File

@@ -169,25 +169,28 @@ static char*
get_words(void)
{
FILE *pp = NULL;
static char buf[BUFSIZ];
static char buf[512];
long n;
if(appres.text_prog){
if (appres.text_prog) {
pp = popen(appres.text_prog, "r");
if(!pp){
warn ("popen %s", appres.text_prog);
if (!pp) {
warn("popen %s", appres.text_prog);
return appres.text;
}
fread(buf, BUFSIZ, 1, pp);
n = fread(buf, 1, sizeof(buf) - 1, pp);
buf[n] = 0;
pclose(pp);
return buf;
}
if(appres.file){
if (appres.file) {
pp = fopen(appres.file, "r");
if(!pp){
warn ("fopen %s", appres.file);
if (!pp) {
warn("fopen %s", appres.file);
return appres.text;
}
fread(buf, BUFSIZ, 1, pp);
n = fread(buf, 1, sizeof(buf) - 1, pp);
buf[n] = 0;
fclose(pp);
return buf;
}