Opened 12 years ago

Closed 12 years ago

#4201 closed Bugs (fixed)

boost/asio/detail/socket_ops.hpp:1305: isdigit called with char, not unsigned char

Reported by: anonymous Owned by: chris_kohlhoff
Milestone: Boost 1.43.0 Component: asio
Version: Boost 1.43.0 Severity: Problem
Keywords: Cc:

Description

As of r61840 file boost/asio/detail/socket_ops.hpp at function gai_serv, there is a call on line 1305 to isdigit which passes serv[0], where serv is declared as a const char*. This causes warning C6328 from the Microsoft code analysis tool PREfast, because isdigit should take an unsigned char, but char is signed if not otherwise specified. Some implementations of ctype.h functions assume that the input is in the range [0, 255], and will misbehave if given a value less than zero. The attached patch requests that the compiler zero-extend the value, which both removes the warning and fixes the problem that the warning is intended to address.

Attachments (1)

foo (341 bytes ) - added by anonymous 12 years ago.
Patch to boost/asio/detail/socket_ops.hpp to add a static_cast to ensure use of a zero-extending move of serv[0]

Download all attachments as: .zip

Change History (3)

by anonymous, 12 years ago

Attachment: foo added

Patch to boost/asio/detail/socket_ops.hpp to add a static_cast to ensure use of a zero-extending move of serv[0]

comment:1 by chris_kohlhoff, 12 years ago

(In [62556]) Ensure unsigned char is used with isdigit. Refs #4201.

comment:2 by chris_kohlhoff, 12 years ago

Resolution: fixed
Status: newclosed

(In [62644]) Merge from trunk.

........

r62497 | chris_kohlhoff | 2010-06-07 09:28:58 +1000 (Mon, 07 Jun 2010) | 2 lines

Fix handling of small but non-zero timeouts. Fixes #4205.

........

r62499 | chris_kohlhoff | 2010-06-07 10:00:45 +1000 (Mon, 07 Jun 2010) | 2 lines

Reworked implementation MkII. Also fixes #4170.

........

r62530 | chris_kohlhoff | 2010-06-08 09:24:28 +1000 (Tue, 08 Jun 2010) | 2 lines

Fixes for MSVC 7.1, Borland.

........

r62531 | chris_kohlhoff | 2010-06-08 09:29:05 +1000 (Tue, 08 Jun 2010) | 2 lines

Some changes for Symbian support.

........

r62549 | chris_kohlhoff | 2010-06-08 14:27:26 +1000 (Tue, 08 Jun 2010) | 2 lines

Fix typo in tutorial. Fixes #4252.

........

r62556 | chris_kohlhoff | 2010-06-08 19:01:39 +1000 (Tue, 08 Jun 2010) | 2 lines

Ensure unsigned char is used with isdigit. Fixes #4201.

........

r62558 | chris_kohlhoff | 2010-06-08 21:01:57 +1000 (Tue, 08 Jun 2010) | 2 lines

Fix handling of empty buffer sequences.

........

Note: See TracTickets for help on using tickets.