Hi,
At 04.38 24/05/2009, Adrian Chadd wrote:
>Can you craft a small C program to replicate the behaviour?
Sure, I wrote the following test program:
#include <stdio.h>
#include <Winsock2.h>
void main(void)
{
u_short i, converted;
WSADATA wsaData;
struct servent *port = NULL;
char token[32];
const char proto[] = "tcp";
WSAStartup(2, &wsaData);
for (i=1; i<65535; i++)
{
sprintf(token, "%d", i);
port = getservbyname(token, proto);
if (port != NULL) {
converted=ntohs((u_short) port->s_port);
if (i != converted)
printf("%d %d\n", i, converted);
}
}
WSACleanup();
}
And this is the result on my Windows XP x64 machine (similar results
on Windows 2000 and Vista):
2 512
258 513
524 3074
770 515
782 3587
1288 2053
1792 7
1807 3847
2050 520
2234 47624
2304 9
2311 1801
2562 522
2564 1034
2816 11
3328 13
3586 526
3853 3343
4352 17
4354 529
4610 530
4864 19
4866 531
5120 20
5122 532
5376 21
5632 22
5888 23
6400 25
7170 540
7938 543
8194 544
8706 546
8962 547
9472 37
10752 42
10767 3882
11008 43
11266 556
12054 5679
13058 563
13568 53
13570 565
13579 2869
14380 11320
14856 2106
15372 3132
15629 3389
16165 9535
16897 322
17920 70
18182 1607
18183 1863
19977 2382
20224 79
20233 2383
20480 80
20736 81
20738 593
21764 1109
22528 88
22550 5720
22793 2393
23049 2394
23809 349
24335 3935
25602 612
25856 101
25858 613
26112 102
27392 107
27655 1900
27904 109
28160 110
28416 111
28928 113
29952 117
30208 118
30222 3702
30464 119
31746 636
34049 389
34560 135
35072 137
35584 139
36106 2701
36362 2702
36608 143
36618 2703
36874 2704
37905 4500
38400 150
38919 1944
39173 1433
39426 666
39429 1434
39936 156
39945 2460
40448 158
42250 2725
43520 170
44806 1711
45824 179
45826 691
47383 6073
47624 2234
47873 443
47878 1723
48385 445
49166 3776
49664 194
49926 1731
50188 3268
50437 1477
50444 3269
50693 1478
51209 2504
52235 3020
53005 3535
53249 464
53510 1745
54285 3540
55309 3544
56070 1755
56579 989
56585 2525
56835 990
57347 992
57603 993
57859 994
58115 995
59397 1512
60674 749
62469 1524
62980 1270
64257 507
65040 4350
It seems that sometime (!!!) getservbyname() will incorrectly return
something ...
Regards
Guido
>adrian
>
>2009/5/24 Guido Serassio <guido.serassio_at_acmeconsulting.it>:
> > Hi,
> >
> > One user has reported a very strange problem using cache_peer directive on
> > 2.7 STABLE6 running on Windows:
> >
> > When using the following config:
> >
> > cache_peer 192.168.0.63 parent 3329 0 no-query
> > cache_peer rea.acmeconsulting.loc parent 3328 3130
> >
> > the result is always:
> >
> > 2009/05/23 12:35:28| Configuring 192.168.0.63 Parent 192.168.0.63/3329/0
> > 2009/05/23 12:35:28| Configuring rea.acmeconsulting.loc Parent
> > rea.acmeconsulting.loc/13/3130
> >
> > Very odd ....
> >
> > Debugging the code, I have found where is situated the problem.
> >
> > The following if GetService() from cache_cf.c:
> >
> > static u_short
> > GetService(const char *proto)
> > {
> > struct servent *port = NULL;
> > char *token = strtok(NULL, w_space);
> > if (token == NULL) {
> > self_destruct();
> > return -1; /* NEVER REACHED */
> > }
> > port = getservbyname(token, proto);
> > if (port != NULL) {
> > return ntohs((u_short) port->s_port);
> > }
> > return xatos(token);
> > }
> >
> > When the value of port->s_port is 3328, ntohs() always returns 13.
> > Other values seems to work fine.
> >
> > Any idea ?
> >
> > Regards
> >
> > Guido
> >
> >
> >
> > -
> > ========================================================
> > Guido Serassio
> > Acme Consulting S.r.l. - Microsoft Certified Partner
> > Via Lucia Savarino, 1 10098 - Rivoli (TO) - ITALY
> > Tel. : +39.011.9530135 Fax. : +39.011.9781115
> > Email: guido.serassio_at_acmeconsulting.it
> > WWW: http://www.acmeconsulting.it/
> >
> >
-
========================================================
Guido Serassio
Acme Consulting S.r.l. - Microsoft Certified Partner
Via Lucia Savarino, 1 10098 - Rivoli (TO) - ITALY
Tel. : +39.011.9530135 Fax. : +39.011.9781115
Email: guido.serassio_at_acmeconsulting.it
WWW: http://www.acmeconsulting.it/
Received on Sun May 24 2009 - 09:55:12 MDT
This archive was generated by hypermail 2.2.0 : Sun May 24 2009 - 12:00:02 MDT