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:
@@ -169,25 +169,28 @@ static char*
|
|||||||
get_words(void)
|
get_words(void)
|
||||||
{
|
{
|
||||||
FILE *pp = NULL;
|
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");
|
pp = popen(appres.text_prog, "r");
|
||||||
if(!pp){
|
if (!pp) {
|
||||||
warn ("popen %s", appres.text_prog);
|
warn("popen %s", appres.text_prog);
|
||||||
return appres.text;
|
return appres.text;
|
||||||
}
|
}
|
||||||
fread(buf, BUFSIZ, 1, pp);
|
n = fread(buf, 1, sizeof(buf) - 1, pp);
|
||||||
|
buf[n] = 0;
|
||||||
pclose(pp);
|
pclose(pp);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
if(appres.file){
|
if (appres.file) {
|
||||||
pp = fopen(appres.file, "r");
|
pp = fopen(appres.file, "r");
|
||||||
if(!pp){
|
if (!pp) {
|
||||||
warn ("fopen %s", appres.file);
|
warn("fopen %s", appres.file);
|
||||||
return appres.text;
|
return appres.text;
|
||||||
}
|
}
|
||||||
fread(buf, BUFSIZ, 1, pp);
|
n = fread(buf, 1, sizeof(buf) - 1, pp);
|
||||||
|
buf[n] = 0;
|
||||||
fclose(pp);
|
fclose(pp);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user