summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--dpi/bookmarks.c10
-rw-r--r--dpi/cookies.c18
-rw-r--r--dpi/datauri.c4
-rw-r--r--dpi/downloads.cc6
-rw-r--r--dpi/file.c4
-rw-r--r--dpi/ftp.c4
-rw-r--r--dpi/hello.c6
-rw-r--r--dpi/https.c18
-rw-r--r--dpid/dpid.c2
-rw-r--r--dpid/main.c2
-rw-r--r--dpip/dpip.c18
-rw-r--r--dpip/dpip.h3
-rw-r--r--src/IO/dpi.c16
-rw-r--r--src/cookies.c2
-rw-r--r--src/dpiapi.c12
16 files changed, 69 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e610fe3..b92ebd37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ dillo-2.2 [??]
+- Cleaned up system includes in dpid directory.
- Fixed CustProgressBox() for systems without weak symbols.
- Handle signed chars. Added dIsspace() and dIsalnum() to dlib.
+ - Added a_Dpip_get_attr_l() to DPIP's API.
Patches: Jorge Arellano Cid
+- Fix segfault from AREA when MAP is missing name attribute.
Patch: corvid
diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c
index da4f422a..8485727b 100644
--- a/dpi/bookmarks.c
+++ b/dpi/bookmarks.c
@@ -1580,11 +1580,11 @@ static int Bmsrv_parse_buf(SockHandler *sh, char *Buf)
}
BufSize = strlen(Buf);
- cmd = a_Dpip_get_attr(Buf, BufSize, "cmd");
+ cmd = a_Dpip_get_attr_l(Buf, BufSize, "cmd");
if (cmd && strcmp(cmd, "chat") == 0) {
dFree(cmd);
- msg = a_Dpip_get_attr(Buf, BufSize, "msg");
+ msg = a_Dpip_get_attr_l(Buf, BufSize, "msg");
if (*msg == 'H') {
/* "Hi server" */
if (sock_handler_write_str(sh, 1, msg1))
@@ -1611,8 +1611,8 @@ static int Bmsrv_parse_buf(SockHandler *sh, char *Buf)
} else if (cmd && strcmp(cmd, "add_bookmark") == 0) {
dFree(cmd);
- url = a_Dpip_get_attr(Buf, BufSize, "url");
- title = a_Dpip_get_attr(Buf, BufSize, "title");
+ url = a_Dpip_get_attr_l(Buf, BufSize, "url");
+ title = a_Dpip_get_attr_l(Buf, BufSize, "title");
if (strlen(title) == 0) {
dFree(title);
title = dStrdup("(Untitled)");
@@ -1625,7 +1625,7 @@ static int Bmsrv_parse_buf(SockHandler *sh, char *Buf)
} else if (cmd && strcmp(cmd, "open_url") == 0) {
dFree(cmd);
- url = a_Dpip_get_attr(Buf, BufSize, "url");
+ url = a_Dpip_get_attr_l(Buf, BufSize, "url");
if (strcmp(url, "dpi:/bm/modify") == 0) {
st = Bmsrv_send_modify_answer(sh, url);
diff --git a/dpi/cookies.c b/dpi/cookies.c
index d8eb4338..21f4c1dc 100644
--- a/dpi/cookies.c
+++ b/dpi/cookies.c
@@ -1354,7 +1354,7 @@ static int srv_parse_buf(SockHandler *sh, char *Buf, size_t BufSize)
return 1;
}
- cmd = a_Dpip_get_attr(Buf, BufSize, "cmd");
+ cmd = a_Dpip_get_attr_l(Buf, BufSize, "cmd");
if (cmd && strcmp(cmd, "DpiBye") == 0) {
dFree(cmd);
@@ -1363,10 +1363,10 @@ static int srv_parse_buf(SockHandler *sh, char *Buf, size_t BufSize)
} else if (cmd && strcmp(cmd, "set_cookie") == 0) {
dFree(cmd);
- cookie = a_Dpip_get_attr(Buf, BufSize, "cookie");
- host = a_Dpip_get_attr(Buf, BufSize, "host");
- path = a_Dpip_get_attr(Buf, BufSize, "path");
- p = a_Dpip_get_attr(Buf, BufSize, "port");
+ cookie = a_Dpip_get_attr_l(Buf, BufSize, "cookie");
+ host = a_Dpip_get_attr_l(Buf, BufSize, "host");
+ path = a_Dpip_get_attr_l(Buf, BufSize, "path");
+ p = a_Dpip_get_attr_l(Buf, BufSize, "port");
port = strtol(p, NULL, 10);
dFree(p);
@@ -1379,10 +1379,10 @@ static int srv_parse_buf(SockHandler *sh, char *Buf, size_t BufSize)
} else if (cmd && strcmp(cmd, "get_cookie") == 0) {
dFree(cmd);
- scheme = a_Dpip_get_attr(Buf, BufSize, "scheme");
- host = a_Dpip_get_attr(Buf, BufSize, "host");
- path = a_Dpip_get_attr(Buf, BufSize, "path");
- p = a_Dpip_get_attr(Buf, BufSize, "port");
+ scheme = a_Dpip_get_attr_l(Buf, BufSize, "scheme");
+ host = a_Dpip_get_attr_l(Buf, BufSize, "host");
+ path = a_Dpip_get_attr_l(Buf, BufSize, "path");
+ p = a_Dpip_get_attr_l(Buf, BufSize, "port");
port = strtol(p, NULL, 10);
dFree(p);
diff --git a/dpi/datauri.c b/dpi/datauri.c
index dd0dbf7f..d620176b 100644
--- a/dpi/datauri.c
+++ b/dpi/datauri.c
@@ -291,8 +291,8 @@ int main(void)
dpip_tag = sock_handler_read(sh);
MSG("[%s]\n", dpip_tag);
- cmd = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cmd");
- url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "url");
+ cmd = a_Dpip_get_attr(dpip_tag, "cmd");
+ url = a_Dpip_get_attr(dpip_tag, "url");
if (!cmd || !url) {
MSG("Error, cmd=%s, url=%s\n", cmd, url);
exit (EXIT_FAILURE);
diff --git a/dpi/downloads.cc b/dpi/downloads.cc
index d92f6e90..619a6760 100644
--- a/dpi/downloads.cc
+++ b/dpi/downloads.cc
@@ -899,7 +899,7 @@ static void read_req_cb(int req_fd, void *)
close(new_socket);
_MSG("Received tag={%s}\n", tag->str);
- if ((cmd = a_Dpip_get_attr(tag->str, (size_t)tag->len, "cmd")) == NULL) {
+ if ((cmd = a_Dpip_get_attr(tag->str, "cmd")) == NULL) {
MSG("Failed to parse 'cmd' in {%s}\n", tag->str);
goto end;
}
@@ -911,11 +911,11 @@ static void read_req_cb(int req_fd, void *)
MSG("unknown command: '%s'. Aborting.\n", cmd);
goto end;
}
- if (!(url = a_Dpip_get_attr(tag->str,(size_t)tag->len, "url"))){
+ if (!(url = a_Dpip_get_attr(tag->str, "url"))){
MSG("Failed to parse 'url' in {%s}\n", tag->str);
goto end;
}
- if (!(dl_dest = a_Dpip_get_attr(tag->str,(size_t)tag->len,"destination"))){
+ if (!(dl_dest = a_Dpip_get_attr(tag->str, "destination"))){
MSG("Failed to parse 'destination' in {%s}\n", tag->str);
goto end;
}
diff --git a/dpi/file.c b/dpi/file.c
index b265b32b..ce7dcee7 100644
--- a/dpi/file.c
+++ b/dpi/file.c
@@ -854,12 +854,12 @@ static void *File_serve_client(void *data)
_MSG("dpip_tag={%s}\n", dpip_tag);
if (dpip_tag) {
- cmd = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cmd");
+ cmd = a_Dpip_get_attr(dpip_tag, "cmd");
if (cmd) {
if (strcmp(cmd, "DpiBye") == 0) {
DPIBYE = 1;
} else {
- url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "url");
+ url = a_Dpip_get_attr(dpip_tag, "url");
if (!url)
MSG("file.dpi:: Failed to parse 'url'\n");
}
diff --git a/dpi/ftp.c b/dpi/ftp.c
index 08ede059..7fff72ca 100644
--- a/dpi/ftp.c
+++ b/dpi/ftp.c
@@ -288,8 +288,8 @@ int main(int argc, char **argv)
dpip_tag = sock_handler_read(sh);
MSG("tag=[%s]\n", dpip_tag);
- cmd = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cmd");
- url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "url");
+ cmd = a_Dpip_get_attr(dpip_tag, "cmd");
+ url = a_Dpip_get_attr(dpip_tag, "url");
if (!cmd || !url) {
MSG("ERROR, cmd=%s, url=%s\n", cmd, url);
exit (EXIT_FAILURE);
diff --git a/dpi/hello.c b/dpi/hello.c
index 250a4a44..c28c5b6b 100644
--- a/dpi/hello.c
+++ b/dpi/hello.c
@@ -56,8 +56,8 @@ int main(void)
dpip_tag = sock_handler_read(sh);
MSG("tag = [%s]\n", dpip_tag);
- cmd = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cmd");
- url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "url");
+ cmd = a_Dpip_get_attr(dpip_tag, "cmd");
+ url = a_Dpip_get_attr(dpip_tag, "url");
/*-- Dialog part */
{
@@ -77,7 +77,7 @@ int main(void)
MSG("tag = [%s]\n", dpip_tag2);
/* Get "msg" value */
- dialog_msg = a_Dpip_get_attr(dpip_tag2, strlen(dpip_tag2), "msg");
+ dialog_msg = a_Dpip_get_attr(dpip_tag2, "msg");
choice_num = 0;
if (dialog_msg)
choice_num = *dialog_msg - '0';
diff --git a/dpi/https.c b/dpi/https.c
index 34d2b5f3..b8d5b1a9 100644
--- a/dpi/https.c
+++ b/dpi/https.c
@@ -108,7 +108,7 @@ static int dialog_get_answer_number(void)
/* Read the dpi command from STDIN */
dpip_tag = sock_handler_read(sh);
- response = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "msg");
+ response = a_Dpip_get_attr(dpip_tag, "msg");
response_number = (response) ? strtol (response, NULL, 10) : -1;
dFree(dpip_tag);
dFree(response);
@@ -194,12 +194,12 @@ static void yes_ssl_support(void)
/*Get the network address and command to be used*/
dpip_tag = sock_handler_read(sh);
- cmd = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cmd");
- proxy_url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "proxy_url");
+ cmd = a_Dpip_get_attr(dpip_tag, "cmd");
+ proxy_url = a_Dpip_get_attr(dpip_tag, "proxy_url");
proxy_connect =
- a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "proxy_connect");
- url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "url");
- http_query = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "query");
+ a_Dpip_get_attr(dpip_tag, "proxy_connect");
+ url = a_Dpip_get_attr(dpip_tag, "url");
+ http_query = a_Dpip_get_attr(dpip_tag, "query");
if (cmd == NULL || url == NULL || http_query == NULL){
MSG("***Value of cmd, url or http_query is NULL"
@@ -699,9 +699,9 @@ static void no_ssl_support(void)
MSG("{In https.filter.dpi}\n");
MSG("no_ssl_support version\n");
- cmd = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cmd");
- url = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "url");
- http_query = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "query");
+ cmd = a_Dpip_get_attr(dpip_tag, "cmd");
+ url = a_Dpip_get_attr(dpip_tag, "url");
+ http_query = a_Dpip_get_attr(dpip_tag, "query");
MSG("{ cmd: %s}\n", cmd);
MSG("{ url: %s}\n", url);
diff --git a/dpid/dpid.c b/dpid/dpid.c
index 45324730..8d325694 100644
--- a/dpid/dpid.c
+++ b/dpid/dpid.c
@@ -859,7 +859,7 @@ char *get_message(int sock, char *dpi_tag)
{
char *msg, *d_cmd;
- msg = a_Dpip_get_attr(dpi_tag, strlen(dpi_tag), "msg");
+ msg = a_Dpip_get_attr(dpi_tag, "msg");
if (msg == NULL) {
ERRMSG("get_message", "failed to parse msg", 0);
d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s",
diff --git a/dpid/main.c b/dpid/main.c
index 969ef690..7ecae76a 100644
--- a/dpid/main.c
+++ b/dpid/main.c
@@ -155,7 +155,7 @@ static int get_command(int sock, char *dpi_tag)
return (-1);
}
- cmd = a_Dpip_get_attr(dpi_tag, strlen(dpi_tag), "cmd");
+ cmd = a_Dpip_get_attr(dpi_tag, "cmd");
if (cmd == NULL) {
ERRMSG("get_command", "a_Dpip_get_attr", 0);
diff --git a/dpip/dpip.c b/dpip/dpip.c
index 5d83a2e9..bf6667d3 100644
--- a/dpip/dpip.c
+++ b/dpip/dpip.c
@@ -107,17 +107,18 @@ char *a_Dpip_build_cmd(const char *format, ...)
}
/*
- * Task: given a tag and an attribute name, return its value.
- * (stuffing of ' is removed here)
+ * Task: given a tag, its size and an attribute name, return the
+ * attribute value (stuffing of ' is removed here).
+ *
* Return value: the attribute value, or NULL if not present or malformed.
*/
-char *a_Dpip_get_attr(char *tag, size_t tagsize, const char *attrname)
+char *a_Dpip_get_attr_l(char *tag, size_t tagsize, const char *attrname)
{
uint_t i, n = 0, found = 0;
char *p, *q, *start, *val = NULL;
DpipTagParsingState state = SEEK_NAME;
- if (!attrname || !*attrname)
+ if (!tag || !tagsize || !attrname || !*attrname)
return NULL;
for (i = 1; i < tagsize && !found; ++i) {
@@ -164,5 +165,14 @@ char *a_Dpip_get_attr(char *tag, size_t tagsize, const char *attrname)
return val;
}
+/*
+ * Task: given a tag and an attribute name, return its value.
+ * Return value: the attribute value, or NULL if not present or malformed.
+ */
+char *a_Dpip_get_attr(char *tag, const char *attrname)
+{
+ return (tag ? a_Dpip_get_attr_l(tag, strlen(tag), attrname) : NULL);
+}
+
/* ------------------------------------------------------------------------- */
diff --git a/dpip/dpip.h b/dpip/dpip.h
index 29bb5fcf..584bf89e 100644
--- a/dpip/dpip.h
+++ b/dpip/dpip.h
@@ -23,7 +23,8 @@ char *a_Dpip_build_cmd(const char *format, ...);
* (dpip character escaping is removed here)
* Return value: the attribute value, or NULL if not present or malformed.
*/
-char *a_Dpip_get_attr(char *tag, size_t tagsize, const char *attrname);
+char *a_Dpip_get_attr(char *tag, const char *attrname);
+char *a_Dpip_get_attr_l(char *tag, size_t tagsize, const char *attrname);
#ifdef __cplusplus
diff --git a/src/IO/dpi.c b/src/IO/dpi.c
index 3ad1c7ed..34932a6a 100644
--- a/src/IO/dpi.c
+++ b/src/IO/dpi.c
@@ -221,14 +221,14 @@ static void Dpi_parse_token(dpi_conn_t *conn)
tag = dStrndup(Tok, (size_t)conn->TokSize);
_MSG("Dpi_parse_token: {%s}\n", tag);
- cmd = a_Dpip_get_attr(Tok, conn->TokSize, "cmd");
+ cmd = a_Dpip_get_attr_l(Tok, conn->TokSize, "cmd");
if (strcmp(cmd, "send_status_message") == 0) {
- msg = a_Dpip_get_attr(Tok, conn->TokSize, "msg");
+ msg = a_Dpip_get_attr_l(Tok, conn->TokSize, "msg");
a_Chain_fcb(OpSend, conn->InfoRecv, msg, cmd);
dFree(msg);
} else if (strcmp(cmd, "chat") == 0) {
- msg = a_Dpip_get_attr(Tok, conn->TokSize, "msg");
+ msg = a_Dpip_get_attr_l(Tok, conn->TokSize, "msg");
a_Chain_fcb(OpSend, conn->InfoRecv, msg, cmd);
dFree(msg);
@@ -238,13 +238,13 @@ static void Dpi_parse_token(dpi_conn_t *conn)
} else if (strcmp(cmd, "start_send_page") == 0) {
conn->Send2EOF = 1;
- urlstr = a_Dpip_get_attr(Tok, conn->TokSize, "url");
+ urlstr = a_Dpip_get_attr_l(Tok, conn->TokSize, "url");
a_Chain_fcb(OpSend, conn->InfoRecv, urlstr, cmd);
dFree(urlstr);
- /* TODO: a_Dpip_get_attr(Tok, conn->TokSize, "send_mode") */
+ /* TODO: a_Dpip_get_attr_l(Tok, conn->TokSize, "send_mode") */
} else if (strcmp(cmd, "reload_request") == 0) {
- urlstr = a_Dpip_get_attr(Tok, conn->TokSize, "url");
+ urlstr = a_Dpip_get_attr_l(Tok, conn->TokSize, "url");
a_Chain_fcb(OpSend, conn->InfoRecv, urlstr, cmd);
dFree(urlstr);
}
@@ -531,9 +531,9 @@ static char *Dpi_get_server_uds_name(const char *server_name)
/* Parse reply */
if (rdlen == 0 && rply) {
- cmd = a_Dpip_get_attr(rply, (int)strlen(rply), "cmd");
+ cmd = a_Dpip_get_attr(rply, "cmd");
if (strcmp(cmd, "send_data") == 0)
- server_uds_name = a_Dpip_get_attr(rply, (int)strlen(rply), "msg");
+ server_uds_name = a_Dpip_get_attr(rply, "msg");
dFree(cmd);
dFree(rply);
}
diff --git a/src/cookies.c b/src/cookies.c
index 745614ca..8c482cbc 100644
--- a/src/cookies.c
+++ b/src/cookies.c
@@ -207,7 +207,7 @@ char *a_Cookies_get_query(const DilloUrl *request_url)
query = dStrdup("Cookie2: $Version=\"1\"\r\n");
if (dpip_tag != NULL) {
- char *cookie = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cookie");
+ char *cookie = a_Dpip_get_attr(dpip_tag, "cookie");
char *old_query = query;
query = dStrconcat(old_query, cookie, NULL);
dFree(old_query);
diff --git a/src/dpiapi.c b/src/dpiapi.c
index 705d6777..2068146c 100644
--- a/src/dpiapi.c
+++ b/src/dpiapi.c
@@ -61,12 +61,12 @@ void a_Dpiapi_dialog(BrowserWindow *bw, char *server, char *dpip_tag)
/* other options can be parsed the same way */
dpip_tag_len = strlen(dpip_tag);
- question = a_Dpip_get_attr(dpip_tag, dpip_tag_len, "msg");
- alt1 = a_Dpip_get_attr(dpip_tag, dpip_tag_len, "alt1");
- alt2 = a_Dpip_get_attr(dpip_tag, dpip_tag_len, "alt2");
- alt3 = a_Dpip_get_attr(dpip_tag, dpip_tag_len, "alt3");
- alt4 = a_Dpip_get_attr(dpip_tag, dpip_tag_len, "alt4");
- alt5 = a_Dpip_get_attr(dpip_tag, dpip_tag_len, "alt5");
+ question = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "msg");
+ alt1 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt1");
+ alt2 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt2");
+ alt3 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt3");
+ alt4 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt4");
+ alt5 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt5");
ret = a_Dialog_choice5(question, alt1, alt2, alt3, alt4, alt5);
/* As choice5 is modal, call the callback function directly. */