Revision 4b8e42f9

View differences:

src/config.c
6 6

  
7 7
#include <stdlib.h>
8 8
#include <string.h>
9
#include <stdio.h>
9 10
#include "config.h"
10 11

  
11 12
#define NAME_SIZE 32
......
37 38
      if (i % MAX_TAGS == 0) {
38 39
        res = realloc(res, sizeof(struct tag) * (i + MAX_TAGS));
39 40
      }
41
      if (p1 - p > NAME_SIZE - 1) {
42
        fprintf(stderr, "Error, config name too long:%s\n", p);
43
        free(res);
44
        return NULL;
45
      }
40 46
      memcpy(res[i].name, p, p1 - p);
41 47
      p = strchr(p1, ',');
42 48
      if (p == NULL) {
43
        strcpy(res[i++].value, p1 + 1);
44
      } else {
45
        memcpy(res[i++].value, p1 + 1, p - p1 - 1);
46
        p++;
49
        p = p1 + strlen(p1);
50
      }
51
      if (p - p1 > VAL_SIZE - 1) {
52
        fprintf(stderr, "Error, config value too long:%s\n", p1);
53
        free(res);
54
        return NULL;
47 55
      }
56
      memcpy(res[i++].value, p1 + 1, p - p1 - 1);
57
      p++;
48 58
    } else {
49 59
      p = NULL;
50 60
    }

Also available in: Unified diff