From cd29a7cb54d998c3b0059e408f744c5db1c398ae Mon Sep 17 00:00:00 2001 From: Heng Li Date: Wed, 23 Jan 2019 13:23:25 -0500 Subject: [PATCH] r1198: exit if .alt is malformatted Resolves #232 --- bntseq.c | 8 +++++++- main.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bntseq.c b/bntseq.c index 65f7e93..bf67bd4 100644 --- a/bntseq.c +++ b/bntseq.c @@ -197,7 +197,13 @@ bntseq_t *bns_restore(const char *prefix) } while (c != '\n' && c != EOF) c = fgetc(fp); i = 0; - } else str[i++] = c; // FIXME: potential segfault here + } else { + if (i >= 1022) { + fprintf(stderr, "[E::%s] sequence name longer than 1023 characters. Abort!\n", __func__); + exit(1); + } + str[i++] = c; + } } kh_destroy(str, h); fclose(fp); diff --git a/main.c b/main.c index 24412da..ff36b71 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.17-r1194-dirty" +#define PACKAGE_VERSION "0.7.17-r1198-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);