Revision 62e64905 conf/cf-lex.l

View differences:

conf/cf-lex.l
124 124
}
125 125

  
126 126
[02]:{DIGIT}+:{DIGIT}+ {
127
  unsigned long int l, len1, len2;
127 128
  char *e;
128
  unsigned long int l;
129 129

  
130 130
  if (yytext[0] == '0')
131
  {
131 132
    cf_lval.i64 = 0;
133
    len1 = 16;
134
    len2 = 32;
135
  }
132 136
  else
133
    cf_lval.i64 = 0x2000000000000ULL;
137
  {
138
    cf_lval.i64 = 2ULL << 48;
139
    len1 = 32;
140
    len2 = 16;
141
  }
134 142

  
135 143
  errno = 0;
136 144
  l = strtoul(yytext+2, &e, 10);
137
  if (e && (*e != ':') || errno == ERANGE || (yytext[0] == '0') && (l >= (1<<16)))
145
  if (e && (*e != ':') || (errno == ERANGE) || (l >> len1))
138 146
    cf_error("ASN out of range");
139
  cf_lval.i64 |= (((u64) l) << 32);
147
  cf_lval.i64 |= ((u64) l) << len2;
148

  
140 149
  errno = 0;
141 150
  l = strtoul(e+1, &e, 10);
142
  if (e && *e || errno == ERANGE || (yytext[0] == '2') && (l >= (1<<16)))
143
    cf_error("Assigned number out of range");
151
  if (e && *e || (errno == ERANGE) || (l >> len2))
152
    cf_error("Number out of range");
144 153
  cf_lval.i64 |= l;
154

  
145 155
  return VPN_RD;
146 156
}
147 157

  
148 158
1:{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+:{DIGIT}+ {
149 159
  unsigned long int l;
150
  char *e = strchr(yytext+2, ':');
151
  *e++ = '\0';
152 160
  ip4_addr ip4;
161
  char *e;
162

  
163
  cf_lval.i64 = 1ULL << 48;
164

  
165
  e = strchr(yytext+2, ':');
166
  *e++ = '\0';
153 167
  if (!ip4_pton(yytext+2, &ip4))
154 168
    cf_error("Invalid IPv4 address %s in Route Distinguisher", yytext+2);
169
  cf_lval.i64 |= ((u64) ip4_to_u32(ip4)) << 16;
170

  
155 171
  errno = 0;
156 172
  l = strtoul(e, &e, 10);
157
  if (e && *e || errno == ERANGE || (l >= (1<<16)))
158
    cf_error("Assigned number out of range");
159
  cf_lval.i64 = (1ULL<<48) | (((u64)ip4_to_u32(ip4)) << 16) | ((u64)l);
173
  if (e && *e || (errno == ERANGE) || (l >> 16))
174
    cf_error("Number out of range");
175
  cf_lval.i64 |= l;
176

  
160 177
  return VPN_RD;
161 178
}
162 179

  

Also available in: Unified diff