Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 691426 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/script.c (-2 / +23 lines)
Lines 477-488 dumplease: Link Here
477
	fp = NULL;
477
	fp = NULL;
478
#endif
478
#endif
479
479
480
481
	char xbuf[2048];
482
483
	hwaddr_ntoa(buf, (size_t)buf_pos, xbuf, sizeof(xbuf));
484
	loginfox("xbuf1 %s", xbuf);
485
480
	nenv = 0;
486
	nenv = 0;
481
	endp = buf + buf_pos;
487
	endp = buf + buf_pos;
488
	loginfox("buf %p endp %p", buf, endp);
482
	for (bufp = buf; bufp < endp; bufp++) {
489
	for (bufp = buf; bufp < endp; bufp++) {
483
		if (*bufp == '\0')
490
		if (*bufp == '\0') {
491
			loginfox("bufp %zu %p is zero", nenv, bufp);
484
			nenv++;
492
			nenv++;
493
		}
485
	}
494
	}
495
	loginfox("nenv %zu envlen %zu", nenv, ctx->script_envlen);
486
	if (ctx->script_envlen < nenv) {
496
	if (ctx->script_envlen < nenv) {
487
		env = reallocarray(ctx->script_env, nenv + 1, sizeof(*env));
497
		env = reallocarray(ctx->script_env, nenv + 1, sizeof(*env));
488
		if (env == NULL)
498
		if (env == NULL)
Lines 490-503 dumplease: Link Here
490
		ctx->script_env = env;
500
		ctx->script_env = env;
491
		ctx->script_envlen = nenv;
501
		ctx->script_envlen = nenv;
492
	}
502
	}
503
	loginfox("nenv %zu envlen %zu", nenv, ctx->script_envlen);
493
	bufp = buf;
504
	bufp = buf;
494
	envp = ctx->script_env;
505
	envp = ctx->script_env;
506
	loginfox("envp %p", envp);
495
	*envp++ = bufp++;
507
	*envp++ = bufp++;
496
	endp--; /* Avoid setting the last \0 to an invalid pointer */
508
	endp--; /* Avoid setting the last \0 to an invalid pointer */
509
	nenv = 0;
497
	for (; bufp < endp; bufp++) {
510
	for (; bufp < endp; bufp++) {
498
		if (*bufp == '\0')
511
		if (*bufp == '\0') {
512
			loginfox("bufp %zu %p is zero, envp %p", nenv, bufp, envp);
499
			*envp++ = bufp + 1;
513
			*envp++ = bufp + 1;
514
			nenv++;
515
		}
500
	}
516
	}
517
	hwaddr_ntoa(buf, (size_t)buf_pos, xbuf, sizeof(xbuf));
518
	loginfox("xbuf2 %s", xbuf);
519
	loginfox("buf %p endp %p", buf, endp);
520
	loginfox("script %p end %p envp %p", ctx->script_env, ctx->script_env + ctx->script_envlen, envp);
521
	loginfox("diff %zu", envp - ctx->script_env);
501
	*envp = NULL;
522
	*envp = NULL;
502
523
503
	return (ssize_t)nenv;
524
	return (ssize_t)nenv;

Return to bug 691426