aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2005-12-05 20:07:05 +0000
committerDan Fandrich <dan@coneharvesters.com>2005-12-05 20:07:05 +0000
commit8c6f654b2605b13708f685b6d88a555d3915405c (patch)
tree172f05610a660d6709e1f83bd54f1b68dfebc713
parent1d8212e53ab7d4c7ff7ba98360a2eefd9c29e310 (diff)
Added a run-time check to warn if TFTP is going to fail due to portability
issues in the code.
-rw-r--r--docs/KNOWN_BUGS2
-rw-r--r--lib/tftp.c19
2 files changed, 21 insertions, 0 deletions
diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS
index 264cdd788..ae41f65bc 100644
--- a/docs/KNOWN_BUGS
+++ b/docs/KNOWN_BUGS
@@ -3,6 +3,8 @@ join in and help us correct one or more of these! Also be sure to check the
changelog of the current development status, as one or more of these problems
may have been fixed since this was written!
+28. The TFTP code is not portable and will fail on some architectures.
+
26. NTLM authentication using SSPI (on Windows) when (lib)curl is running in
"system context" will make it use wrong(?) user name - at least when compared
to what winhttp does. See http://curl.haxx.se/bug/view.cgi?id=1281867
diff --git a/lib/tftp.c b/lib/tftp.c
index e9d17ee1d..f2cd3fb01 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -529,6 +529,25 @@ CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done)
tftp_state_data_t *state;
int rc;
+ /*
+ * The TFTP code is not portable because it sends C structs directly over
+ * the wire. Since C gives compiler writers a wide latitude in padding and
+ * aligning structs, this fails on many 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.
+ *
+ * This check can be removed once the code has been fixed.
+ */
+ if(sizeof(struct tftp_packet) != 516) {
+ failf(conn->data, "tftp not supported on this architecture");
+ return CURLE_FAILED_INIT;
+ }
+
if((state = conn->proto.tftp = calloc(sizeof(tftp_state_data_t), 1))==NULL) {
return CURLE_OUT_OF_MEMORY;
}