cURL / Mailing Lists / curl-library / Single Mail

curl-library

TFTP portability

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 5 Dec 2005 19:59:40 -0800

I discovered that the new TFTP code is not very portable across
architectures. As it stands, it sends C structs directly over the wire,
which is a no-no when it comes to portability. Since C gives compiler
writers a wide latitude in padding and aligning structs, this can and
does fail on several architectures (e.g. ARM).

The only portable way to fix this is to copy each struct item into a
flat buffer and send the flat buffer instead of the struct. The
alternative, trying to get the compiler to eliminate padding bytes
within the struct, is a nightmare to maintain (each compiler does it
differently), and is still not guaranteed to work because some
architectures can't handle the resulting alignment.

I don't have time to fix this myself right now, so I added a run-time check
on the struct length in Curl_tftp_connect to try to detect any
compiler-added padding bytes. This will cause TFTP to err out immediately
with a CURLE_FAILED_INIT error and an appropriate error message when
run on such a machine. I've also added this to the KNOWN_BUGS document.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
     Let webmasters know that your web site has moved
Received on 2005-12-06