Revision aa3b4b4d deps/openssl/openssl/crypto/objects/obj_dat.c

View differences:

deps/openssl/openssl/crypto/objects/obj_dat.c
471 471
	const unsigned char *p;
472 472
	char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
473 473

  
474
	if ((a == NULL) || (a->data == NULL)) {
475
		buf[0]='\0';
476
		return(0);
477
	}
474
	/* Ensure that, at every state, |buf| is NUL-terminated. */
475
	if (buf && buf_len > 0)
476
		buf[0] = '\0';
478 477

  
478
	if ((a == NULL) || (a->data == NULL))
479
		return(0);
479 480

  
480 481
	if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
481 482
		{
......
554 555
				i=(int)(l/40);
555 556
				l-=(long)(i*40);
556 557
				}
557
			if (buf && (buf_len > 0))
558
			if (buf && (buf_len > 1))
558 559
				{
559 560
				*buf++ = i + '0';
561
				*buf = '\0';
560 562
				buf_len--;
561 563
				}
562 564
			n++;
......
571 573
			i = strlen(bndec);
572 574
			if (buf)
573 575
				{
574
				if (buf_len > 0)
576
				if (buf_len > 1)
575 577
					{
576 578
					*buf++ = '.';
579
					*buf = '\0';
577 580
					buf_len--;
578 581
					}
579 582
				BUF_strlcpy(buf,bndec,buf_len);
......
807 810
	OPENSSL_free(buf);
808 811
	return(ok);
809 812
	}
810

  

Also available in: Unified diff