From 320ff29c4aafd9783a0af53c4041acfe79d6d912 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 22 Jun 2010 11:43:42 -0500 Subject: [PATCH] Fix bad string handling in makeBpt. This behaved badly when confronted with windows CR+LF end of lines. Using fgets() left a stray CR at the end of the returned string. --- src/bpt/makeBpt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bpt/makeBpt.c b/src/bpt/makeBpt.c index 7f5c39602..b88e82a74 100644 --- a/src/bpt/makeBpt.c +++ b/src/bpt/makeBpt.c @@ -144,12 +144,13 @@ int main(int argc, char **argv) if(*pend!='"') errExit("Illegal Header"); len = pend - pbeg; if(len<=1) errExit("Illegal Header"); - pname = calloc(len,sizeof(char)); + pname = calloc(len+1,sizeof(char)); if(!pname) { fprintf(stderr,"calloc failed while processing line %d\n",linenum); exit(-1); } strncpy(pname,pbeg,len); + pname[len]='\0'; pbeg = pend + 1; if(getNumber(&pbeg,&value)) errExit("Illegal Header"); brkCreateInfo.engLow = value;