1%{ 2/*- 3 * Copyright (c) 2009-2010 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * This software was developed by Pawel Jakub Dawidek under sponsorship from 7 * the FreeBSD Foundation. 8 * --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/sbin/hastd/parse.y 214274 2010-10-24 15:41:23Z pjd $ |
31 */ 32 33#include <sys/param.h> /* MAXHOSTNAMELEN */ 34#include <sys/queue.h> 35#include <sys/sysctl.h> 36 37#include <arpa/inet.h> 38 --- 220 unchanged lines hidden (view full) --- 259control_statement: CONTROL STR 260 { 261 switch (depth) { 262 case 0: 263 if (strlcpy(depth0_control, $2, 264 sizeof(depth0_control)) >= 265 sizeof(depth0_control)) { 266 pjdlog_error("control argument is too long."); |
267 free($2); |
268 return (1); 269 } 270 break; 271 case 1: 272 if (!mynode) 273 break; 274 if (strlcpy(lconfig->hc_controladdr, $2, 275 sizeof(lconfig->hc_controladdr)) >= 276 sizeof(lconfig->hc_controladdr)) { 277 pjdlog_error("control argument is too long."); |
278 free($2); |
279 return (1); 280 } 281 break; 282 default: 283 assert(!"control at wrong depth level"); 284 } |
285 free($2); |
286 } 287 ; 288 289listen_statement: LISTEN STR 290 { 291 switch (depth) { 292 case 0: 293 if (strlcpy(depth0_listen, $2, 294 sizeof(depth0_listen)) >= 295 sizeof(depth0_listen)) { 296 pjdlog_error("listen argument is too long."); |
297 free($2); |
298 return (1); 299 } 300 break; 301 case 1: 302 if (!mynode) 303 break; 304 if (strlcpy(lconfig->hc_listenaddr, $2, 305 sizeof(lconfig->hc_listenaddr)) >= 306 sizeof(lconfig->hc_listenaddr)) { 307 pjdlog_error("listen argument is too long."); |
308 free($2); |
309 return (1); 310 } 311 break; 312 default: 313 assert(!"listen at wrong depth level"); 314 } |
315 free($2); |
316 } 317 ; 318 319replication_statement: REPLICATION replication_type 320 { 321 switch (depth) { 322 case 0: 323 depth0_replication = $2; --- 34 unchanged lines hidden (view full) --- 358 359exec_statement: EXEC STR 360 { 361 switch (depth) { 362 case 0: 363 if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >= 364 sizeof(depth0_exec)) { 365 pjdlog_error("Exec path is too long."); |
366 free($2); |
367 return (1); 368 } 369 break; 370 case 1: 371 if (curres == NULL) 372 break; 373 if (strlcpy(curres->hr_exec, $2, 374 sizeof(curres->hr_exec)) >= 375 sizeof(curres->hr_exec)) { 376 pjdlog_error("Exec path is too long."); |
377 free($2); |
378 return (1); 379 } 380 break; 381 default: 382 assert(!"exec at wrong depth level"); 383 } |
384 free($2); |
385 } 386 ; 387 388node_statement: ON node_start OB node_entries CB 389 { 390 mynode = false; 391 } 392 ; 393 394node_start: STR 395 { 396 switch (isitme($1)) { 397 case -1: |
398 free($1); |
399 return (1); 400 case 0: 401 break; 402 case 1: 403 mynode = true; 404 break; 405 default: 406 assert(!"invalid isitme() return value"); 407 } |
408 free($1); |
409 } 410 ; 411 412node_entries: 413 | 414 node_entries node_entry 415 ; 416 --- 71 unchanged lines hidden (view full) --- 488 * resource-level or not. 489 */ 490 depth1_provname[0] = '\0'; 491 depth1_localpath[0] = '\0'; 492 493 curres = calloc(1, sizeof(*curres)); 494 if (curres == NULL) { 495 pjdlog_error("Unable to allocate memory for resource."); |
496 free($1); |
497 return (1); 498 } 499 if (strlcpy(curres->hr_name, $1, 500 sizeof(curres->hr_name)) >= 501 sizeof(curres->hr_name)) { 502 pjdlog_error("Resource name is too long."); |
503 free($1); |
504 return (1); 505 } |
506 free($1); |
507 curres->hr_role = HAST_ROLE_INIT; 508 curres->hr_previous_role = HAST_ROLE_INIT; 509 curres->hr_replication = -1; 510 curres->hr_timeout = -1; 511 curres->hr_exec[0] = '\0'; 512 curres->hr_provname[0] = '\0'; 513 curres->hr_localpath[0] = '\0'; 514 curres->hr_localfd = -1; --- 24 unchanged lines hidden (view full) --- 539name_statement: NAME STR 540 { 541 switch (depth) { 542 case 1: 543 if (strlcpy(depth1_provname, $2, 544 sizeof(depth1_provname)) >= 545 sizeof(depth1_provname)) { 546 pjdlog_error("name argument is too long."); |
547 free($2); |
548 return (1); 549 } 550 break; 551 case 2: 552 if (!mynode) 553 break; 554 assert(curres != NULL); 555 if (strlcpy(curres->hr_provname, $2, 556 sizeof(curres->hr_provname)) >= 557 sizeof(curres->hr_provname)) { 558 pjdlog_error("name argument is too long."); |
559 free($2); |
560 return (1); 561 } 562 break; 563 default: 564 assert(!"name at wrong depth level"); 565 } |
566 free($2); |
567 } 568 ; 569 570local_statement: LOCAL STR 571 { 572 switch (depth) { 573 case 1: 574 if (strlcpy(depth1_localpath, $2, 575 sizeof(depth1_localpath)) >= 576 sizeof(depth1_localpath)) { 577 pjdlog_error("local argument is too long."); |
578 free($2); |
579 return (1); 580 } 581 break; 582 case 2: 583 if (!mynode) 584 break; 585 assert(curres != NULL); 586 if (strlcpy(curres->hr_localpath, $2, 587 sizeof(curres->hr_localpath)) >= 588 sizeof(curres->hr_localpath)) { 589 pjdlog_error("local argument is too long."); |
590 free($2); |
591 return (1); 592 } 593 break; 594 default: 595 assert(!"local at wrong depth level"); 596 } |
597 free($2); |
598 } 599 ; 600 601resource_node_statement:ON resource_node_start OB resource_node_entries CB 602 { 603 mynode = false; 604 } 605 ; 606 607resource_node_start: STR 608 { 609 if (curres != NULL) { 610 switch (isitme($1)) { 611 case -1: |
612 free($1); |
613 return (1); 614 case 0: 615 break; 616 case 1: 617 mynode = true; 618 break; 619 default: 620 assert(!"invalid isitme() return value"); 621 } 622 } |
623 free($1); |
624 } 625 ; 626 627resource_node_entries: 628 | 629 resource_node_entries resource_node_entry 630 ; 631 --- 9 unchanged lines hidden (view full) --- 641 { 642 assert(depth == 2); 643 if (mynode) { 644 assert(curres != NULL); 645 if (strlcpy(curres->hr_remoteaddr, $2, 646 sizeof(curres->hr_remoteaddr)) >= 647 sizeof(curres->hr_remoteaddr)) { 648 pjdlog_error("remote argument is too long."); |
649 free($2); |
650 return (1); 651 } 652 } |
653 free($2); |
654 } 655 ; |