summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@1ts.org>2010-08-22 00:56:13 +0000
committerGravatar Karl Ramm <kcr@1ts.org>2010-08-22 00:56:13 +0000
commitb110bf96d4687ccc35c717dbc750bbb6fa420ee0 (patch)
tree21124558cc420c2790eb92834e3c1664c492d3f2 /server
parente4806cee25df4d4ac2fc725c48936511527f0a88 (diff)
Fix some formatting, and add some paranoia about oversized headers.
(Thanks to nelhage@mit.edu for noticing the formatting problem)
Diffstat (limited to 'server')
-rw-r--r--server/dispatch.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/server/dispatch.c b/server/dispatch.c
index cdc589c..2e701c3 100644
--- a/server/dispatch.c
+++ b/server/dispatch.c
@@ -631,16 +631,21 @@ xmit(ZNotice_t *notice,
return;
}
- if (notice->z_multinotice && strcmp(notice->z_multinotice, ""))
- if (sscanf(notice->z_multinotice, "%d/%d", &origoffset, &origlen)
- != 2)
- {
- syslog(LOG_WARNING, "xmit unauth refrag: parse failed");
- free(buffer);
- return;
- }
-
- fragsize = Z_MAXPKTLEN-hdrlen-Z_FRAGFUDGE;
+ if (notice->z_multinotice && strcmp(notice->z_multinotice, "")) {
+ if (sscanf(notice->z_multinotice, "%d/%d", &origoffset,
+ &origlen) != 2) {
+ syslog(LOG_WARNING, "xmit unauth refrag: parse failed");
+ free(buffer);
+ return;
+ }
+ }
+
+ fragsize = Z_MAXPKTLEN - hdrlen - Z_FRAGFUDGE;
+
+ if (fragsize < 0) {
+ syslog(LOG_ERR, "xmit: negative fragsize, dropping packet");
+ return;
+ }
while (offset < notice->z_message_len || !notice->z_message_len) {
(void) sprintf(multi, "%d/%d", offset+origoffset, origlen);