summaryrefslogtreecommitdiff
path: root/src/htstools.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2014-06-17 19:56:26 +0000
committerXavier Roche <xroche@users.noreply.github.com>2014-06-17 19:56:26 +0000
commit027fe3a5ee5d4e34912752c2410f6a6debe7e6b4 (patch)
tree9aa3645e34ad7e2b600478d2f51bf78083ef20ad /src/htstools.c
parent8b05179083f4af083d36eaed41a64ac0e942eac7 (diff)
Possible cause of crash at htstools.c:425 inside long_to_83()
Diffstat (limited to 'src/htstools.c')
-rw-r--r--src/htstools.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/htstools.c b/src/htstools.c
index af41812..a00ce76 100644
--- a/src/htstools.c
+++ b/src/htstools.c
@@ -415,14 +415,15 @@ void long_to_83(int mode, char *n83, char *save) {
while(*save) {
char fn83[256], fnl[256];
- int i = 0;
+ size_t i, j;
fn83[0] = fnl[0] = '\0';
- while((save[i]) && (save[i] != '/')) {
- fnl[i] = save[i];
- i++;
+ for(i = j = 0 ; save[i] && save[i] != '/' ; i++) {
+ if (j + 1 < sizeof(fnl)) {
+ fnl[j++] = save[i];
+ }
}
- fnl[i] = '\0';
+ fnl[j] = '\0';
// conversion
longfile_to_83(mode, fn83, fnl);
strcatbuff(n83, fn83);