Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
de2b1316
Commit
de2b1316
authored
Apr 12, 2002
by
Leigh B. Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A couple of fixes suggested by Chad, one of which has the potential to
solve the problem with tmcd hanging!
parent
c6342a2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
18 deletions
+41
-18
tmcd/ssl.c
tmcd/ssl.c
+39
-16
tmcd/tmcd.c
tmcd/tmcd.c
+2
-2
No files found.
tmcd/ssl.c
View file @
de2b1316
...
...
@@ -14,6 +14,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -58,7 +59,7 @@ static char *clientcertdirs[] = {
static
SSL
*
ssl
;
static
SSL_CTX
*
ctx
;
static
int
client
=
0
;
static
char
nosslbuf
[
MYBUFSIZE
];
static
char
nosslbuf
[
BUFSIZ
];
static
int
nosslbuflen
,
nosslbufidx
;
static
void
tmcd_sslerror
();
static
void
tmcd_sslprint
(
const
char
*
fmt
,
...);
...
...
@@ -211,18 +212,22 @@ tmcd_sslaccept(int sock, struct sockaddr *addr, socklen_t *addrlen)
/*
* Read the first bit. It indicates whether we need to SSL
* handshake or not.
* handshake or not. Clear the buffer to avoid confusing
* the last connection with this new connection.
*/
if
((
cc
=
read
(
newsock
,
nosslbuf
,
sizeof
(
nosslbuf
)
-
1
))
<=
0
)
{
bzero
(
nosslbuf
,
strlen
(
SPEAKSSL
));
if
((
cc
=
read
(
newsock
,
nosslbuf
,
strlen
(
SPEAKSSL
)))
<=
0
)
{
error
(
"sslaccept: reading request"
);
if
(
cc
==
0
)
errno
=
EIO
;
goto
badauth
;
}
if
(
strncmp
(
nosslbuf
,
SPEAKSSL
,
strlen
(
SPEAKSSL
)))
{
if
(
strncmp
(
nosslbuf
,
SPEAKSSL
,
cc
))
{
/*
* No ssl. Need to return this data on the next read.
* See below.
* See below.
*/
isssl
=
0
;
nosslbuflen
=
cc
;
...
...
@@ -429,22 +434,40 @@ tmcd_sslwrite(int sock, const void *buf, size_t nbytes)
}
/*
* Read stuff in.
* Read stuff in. The nosslbuf stuff is overly general; the caller behaves
* in a much more constrained manner.
*/
int
tmcd_sslread
(
int
sock
,
void
*
buf
,
size_t
nbytes
)
{
int
cc
=
0
;
int
cc
=
0
,
nosslcount
=
0
;
/*
* This cruft only happens on the server.
*/
if
(
nosslbuflen
)
{
char
*
bp
=
(
char
*
)
buf
,
*
cp
=
&
nosslbuf
[
nosslbufidx
];
while
(
cc
<
nbytes
&&
nosslbuflen
)
{
*
bp
=
*
cp
;
bp
++
;
cp
++
;
cc
++
;
nosslbuflen
--
;
nosslbufidx
++
;
}
return
cc
;
nosslcount
=
(
nosslbuflen
>
nbytes
?
nbytes
:
nosslbuflen
);
memcpy
(
buf
,
&
nosslbuf
[
nosslbufidx
],
nosslcount
);
nosslbuflen
-=
nosslcount
;
nosslbufidx
+=
nosslcount
;
if
(
nosslcount
==
nbytes
)
return
nosslcount
;
/*
* The request has to be presented to the caller as a single
* message. Since we read just enough to look for the
* SPEAKSSL tag above, see if there is more, and get it.
*/
if
(
ioctl
(
sock
,
FIONREAD
,
&
cc
)
<
0
)
return
-
1
;
if
(
cc
==
0
)
return
nosslcount
;
nbytes
-=
nosslcount
;
buf
=
(
void
*
)
(((
char
*
)
buf
)
+
nosslcount
);
}
errno
=
0
;
...
...
@@ -459,7 +482,7 @@ tmcd_sslread(int sock, void *buf, size_t nbytes)
}
return
cc
;
}
return
cc
;
return
cc
+
nosslcount
;
}
/*
...
...
tmcd/tmcd.c
View file @
de2b1316
...
...
@@ -66,7 +66,7 @@ int mydb_update(char *query, ...);
#define MINCHILDREN 5
static
int
udpchild
;
static
int
numchildren
;
static
int
maxchildren
=
MINCHILDREN
;
static
int
maxchildren
=
10
;
static
volatile
int
killme
;
#ifdef EVENTSYS
...
...
@@ -450,7 +450,7 @@ handle_request(int sock, struct sockaddr_in *client, char *rdata, int istcp)
while
(
isspace
(
*
bp
))
bp
++
;
/*
* Look for VERSION.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment