summaryrefslogtreecommitdiffabout
path: root/html.c
authorLars Hjemli <hjemli@gmail.com>2006-12-28 00:54:43 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2006-12-28 00:54:43 (UTC)
commit27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6 (patch) (side-by-side diff)
tree041158893604fa4127bc0df31a2c22f8d48b852f /html.c
parentc43f1246cb759eb811ab0ebef0613b86dda99581 (diff)
downloadcgit-27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6.zip
cgit-27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6.tar.gz
cgit-27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6.tar.bz2
Test for NULL-pointers in html_txt() and friends
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'html.c') (more/less context) (ignore whitespace changes)
-rw-r--r--html.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/html.c b/html.c
index 957b326..3a5d28d 100644
--- a/html.c
+++ b/html.c
@@ -36,48 +36,48 @@ void htmlf(const char *format, ...)
static char buf[65536];
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
html(buf);
}
void html_txt(char *txt)
{
char *t = txt;
- while(*t){
+ while(t && *t){
int c = *t;
if (c=='<' || c=='>' || c=='&') {
*t = '\0';
html(txt);
*t = c;
if (c=='>')
html("&gt;");
else if (c=='<')
html("&lt;");
else if (c=='&')
html("&amp;");
txt = t+1;
}
t++;
}
if (t!=txt)
html(txt);
}
void html_ntxt(int len, char *txt)
{
char *t = txt;
- while(*t && len--){
+ while(t && *t && len--){
int c = *t;
if (c=='<' || c=='>' || c=='&') {
*t = '\0';
html(txt);
*t = c;
if (c=='>')
html("&gt;");
else if (c=='<')
html("&lt;");
else if (c=='&')
html("&amp;");
txt = t+1;
@@ -88,25 +88,25 @@ void html_ntxt(int len, char *txt)
char c = *t;
*t = '\0';
html(txt);
*t = c;
}
if (len<0)
html("...");
}
void html_attr(char *txt)
{
char *t = txt;
- while(*t){
+ while(t && *t){
int c = *t;
if (c=='<' || c=='>' || c=='\'') {
*t = '\0';
html(txt);
*t = c;
if (c=='>')
html("&gt;");
else if (c=='<')
html("&lt;");
else if (c=='\'')
html("&quote;");
txt = t+1;
@@ -146,13 +146,12 @@ void html_fileperm(unsigned short mode)
void html_filemode(unsigned short mode)
{
if (S_ISDIR(mode))
html("d");
else if (S_ISLNK(mode))
html("l");
else
html("-");
html_fileperm(mode >> 6);
html_fileperm(mode >> 3);
html_fileperm(mode);
}
-