Index: filefuncs.c =================================================================== RCS file: /cvsroot/xmlgawk/xmlgawk/extension/filefuncs.c,v retrieving revision 1.3 diff -b -u -p -r1.3 filefuncs.c --- filefuncs.c 4 Apr 2005 21:25:56 -0000 1.3 +++ filefuncs.c 21 Jun 2005 13:49:29 -0000 @@ -255,17 +255,19 @@ NODE *tree; /* for symbolic links, add a linkval field */ if (S_ISLNK(sbuf.st_mode)) { - char buf[BUFSIZ*2]; + char *buf; int linksize; - linksize = readlink(file->stptr, buf, sizeof buf); - /* should make this smarter */ - if (linksize == sizeof(buf)) - fatal("size of symbolic link too big"); + emalloc(buf, char *, sbuf.st_size + 2, "do_stat"); + if (((linksize = readlink(file->stptr, buf, + sbuf.st_size + 2)) >= 0) && + (linksize <= sbuf.st_size)) { + /* set the linkval field only if we are able to retrieve + the entire link value successfully. */ buf[linksize] = '\0'; - aptr = assoc_lookup(array, tmp_string("linkval", 7), FALSE); - *aptr = make_string(buf, linksize); + *aptr = make_str_node(buf, linksize, ALREADY_MALLOCED); + } } /* add a type field */