List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] Fix segmentation fault in empty repository
@ 2011-11-24 11:54 john
  2012-01-03 20:58 ` hjemli
  0 siblings, 1 reply; 2+ messages in thread
From: john @ 2011-11-24 11:54 UTC (permalink / raw)


When a repository is empty, the ATOM feed link is written in the header,
but this involves formatting ctx->qry.head which is NULL in this case.
With glibc, vsnprintf formats "%s" with a NULL input as "(null)" but on
Solaris this results in a segmentation fault.  Since we don't have a
meaningful head for the atom feed in an empty repository, it's simplest
not to write out the link element at all.

Signed-off-by: John Keeping <john at metanate.com>
---
 ui-shared.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c
index 5aa9119..d9d4149 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -613,7 +613,7 @@ void cgit_print_docstart(struct cgit_context *ctx)
 		html_attr(ctx->cfg.favicon);
 		html("'/>\n");
 	}
-	if (host && ctx->repo) {
+	if (host && ctx->repo && ctx->qry.head) {
 		html("<link rel='alternate' title='Atom feed' href='");
 		html(cgit_httpscheme());
 		html_attr(cgit_hosturl());
-- 
1.7.8.rc3





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Fix segmentation fault in empty repository
  2011-11-24 11:54 [PATCH] Fix segmentation fault in empty repository john
@ 2012-01-03 20:58 ` hjemli
  0 siblings, 0 replies; 2+ messages in thread
From: hjemli @ 2012-01-03 20:58 UTC (permalink / raw)


On Thu, Nov 24, 2011 at 12:54, John Keeping <john at metanate.com> wrote:
> When a repository is empty, the ATOM feed link is written in the header,
> but this involves formatting ctx->qry.head which is NULL in this case.
> With glibc, vsnprintf formats "%s" with a NULL input as "(null)" but on
> Solaris this results in a segmentation fault. ?Since we don't have a
> meaningful head for the atom feed in an empty repository, it's simplest
> not to write out the link element at all.

Thanks, applied to stable.

--
larsh




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-03 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-24 11:54 [PATCH] Fix segmentation fault in empty repository john
2012-01-03 20:58 ` hjemli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).