aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-09-09 17:09:29 +0200
committerThomas White <taw@physics.org>2020-09-09 17:09:29 +0200
commit4a46022b71ea7caf61802a20ae157ccc0841df18 (patch)
treee268f35f79a4d8ed20ac055ea943644e0d45f856 /libcrystfel
parent15956a670c5d1a9ddeb5f2b435eae1a7579fd6ed (diff)
get_matrix_name: Improve string handling
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/symmetry.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libcrystfel/src/symmetry.c b/libcrystfel/src/symmetry.c
index 32c5f6c3..bd2f16b7 100644
--- a/libcrystfel/src/symmetry.c
+++ b/libcrystfel/src/symmetry.c
@@ -1684,21 +1684,24 @@ SymOpList *parse_symmetry_operations(const char *s)
}
-static void add_chars(char *t, const char *s, int max_len)
+static void add_chars(char *t, const char *s, size_t max_len)
{
- char *tmp;
+ size_t len;
- tmp = strdup(t);
+ len = strlen(t) + strlen(s);
+ if ( len > max_len ) {
+ ERROR("get_matrix_name: String too long!\n");
+ return;
+ }
- snprintf(t, max_len, "%s%s", tmp, s);
- free(tmp);
+ strcat(t, s);
}
char *get_matrix_name(const IntegerMatrix *m, int col)
{
char *text;
- const int max_len = 9;
+ const size_t max_len = 31;
int i;
int printed = 0;