diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2005-09-08 16:40:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-09-08 16:40:41 -0400 |
commit | baed16a7ff5194487764db300c2753ac7409c4c5 (patch) | |
tree | a6cc8276bdd41abee85df26a894980a4de5d504c /net | |
parent | 3a93481589dc80d9ff9082731f35031b0345442e (diff) |
[AX.25]: Make asc2ax() thread-proof
Asc2ax was still using a static buffer for all invocations which isn't
exactly SMP-safe. Change asc2ax to take an additional result buffer as
the argument. Change all callers to provide such a buffer.
This one only really is a fix for ROSE and as per recent discussions
there's still much more to fix in ROSE ...
Signed-off-by: Ralf Baechle DL5RB <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ax25/ax25_addr.c | 27 | ||||
-rw-r--r-- | net/rose/rose_subr.c | 4 |
2 files changed, 14 insertions, 17 deletions
diff --git a/net/ax25/ax25_addr.c b/net/ax25/ax25_addr.c index dca179daf415..0164a155b8c4 100644 --- a/net/ax25/ax25_addr.c +++ b/net/ax25/ax25_addr.c | |||
@@ -67,37 +67,34 @@ char *ax2asc(char *buf, ax25_address *a) | |||
67 | /* | 67 | /* |
68 | * ascii -> ax25 conversion | 68 | * ascii -> ax25 conversion |
69 | */ | 69 | */ |
70 | ax25_address *asc2ax(char *callsign) | 70 | void asc2ax(ax25_address *addr, char *callsign) |
71 | { | 71 | { |
72 | static ax25_address addr; | ||
73 | char *s; | 72 | char *s; |
74 | int n; | 73 | int n; |
75 | 74 | ||
76 | for (s = callsign, n = 0; n < 6; n++) { | 75 | for (s = callsign, n = 0; n < 6; n++) { |
77 | if (*s != '\0' && *s != '-') | 76 | if (*s != '\0' && *s != '-') |
78 | addr.ax25_call[n] = *s++; | 77 | addr->ax25_call[n] = *s++; |
79 | else | 78 | else |
80 | addr.ax25_call[n] = ' '; | 79 | addr->ax25_call[n] = ' '; |
81 | addr.ax25_call[n] <<= 1; | 80 | addr->ax25_call[n] <<= 1; |
82 | addr.ax25_call[n] &= 0xFE; | 81 | addr->ax25_call[n] &= 0xFE; |
83 | } | 82 | } |
84 | 83 | ||
85 | if (*s++ == '\0') { | 84 | if (*s++ == '\0') { |
86 | addr.ax25_call[6] = 0x00; | 85 | addr->ax25_call[6] = 0x00; |
87 | return &addr; | 86 | return; |
88 | } | 87 | } |
89 | 88 | ||
90 | addr.ax25_call[6] = *s++ - '0'; | 89 | addr->ax25_call[6] = *s++ - '0'; |
91 | 90 | ||
92 | if (*s != '\0') { | 91 | if (*s != '\0') { |
93 | addr.ax25_call[6] *= 10; | 92 | addr->ax25_call[6] *= 10; |
94 | addr.ax25_call[6] += *s++ - '0'; | 93 | addr->ax25_call[6] += *s++ - '0'; |
95 | } | 94 | } |
96 | 95 | ||
97 | addr.ax25_call[6] <<= 1; | 96 | addr->ax25_call[6] <<= 1; |
98 | addr.ax25_call[6] &= 0x1E; | 97 | addr->ax25_call[6] &= 0x1E; |
99 | |||
100 | return &addr; | ||
101 | } | 98 | } |
102 | 99 | ||
103 | /* | 100 | /* |
diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c index 02891ce2db37..36a77944622b 100644 --- a/net/rose/rose_subr.c +++ b/net/rose/rose_subr.c | |||
@@ -337,13 +337,13 @@ static int rose_parse_ccitt(unsigned char *p, struct rose_facilities_struct *fac | |||
337 | memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN); | 337 | memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN); |
338 | memcpy(callsign, p + 12, l - 10); | 338 | memcpy(callsign, p + 12, l - 10); |
339 | callsign[l - 10] = '\0'; | 339 | callsign[l - 10] = '\0'; |
340 | facilities->source_call = *asc2ax(callsign); | 340 | asc2ax(&facilities->source_call, callsign); |
341 | } | 341 | } |
342 | if (*p == FAC_CCITT_SRC_NSAP) { | 342 | if (*p == FAC_CCITT_SRC_NSAP) { |
343 | memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN); | 343 | memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN); |
344 | memcpy(callsign, p + 12, l - 10); | 344 | memcpy(callsign, p + 12, l - 10); |
345 | callsign[l - 10] = '\0'; | 345 | callsign[l - 10] = '\0'; |
346 | facilities->dest_call = *asc2ax(callsign); | 346 | asc2ax(&facilities->dest_call, callsign); |
347 | } | 347 | } |
348 | p += l + 2; | 348 | p += l + 2; |
349 | n += l + 2; | 349 | n += l + 2; |