~ubuntu-branches/ubuntu/intrepid/curl/intrepid

« back to all changes in this revision

Viewing changes to lib/tftp.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:56:48 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030105648-uo8q8w9xklb40b4k
Tags: 7.15.5-1ubuntu1
* Merge from debian unstable. Remaining Ubuntu changes:
  - debian/control: Drop libdb4.2 build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: tftp.c,v 1.26 2006-05-09 13:02:53 bagder Exp $
 
21
 * $Id: tftp.c,v 1.28 2006-07-29 16:17:36 yangtse Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
228
228
 
229
229
static void setpacketevent(tftp_packet_t *packet, unsigned short num)
230
230
{
231
 
  packet->data[0] = (num >> 8);
232
 
  packet->data[1] = (num & 0xff);
 
231
  packet->data[0] = (unsigned char)(num >> 8);
 
232
  packet->data[1] = (unsigned char)(num & 0xff);
233
233
}
234
234
 
235
235
 
236
236
static void setpacketblock(tftp_packet_t *packet, unsigned short num)
237
237
{
238
 
  packet->data[2] = (num >> 8);
239
 
  packet->data[3] = (num & 0xff);
 
238
  packet->data[2] = (unsigned char)(num >> 8);
 
239
  packet->data[3] = (unsigned char)(num & 0xff);
240
240
}
241
241
 
242
242
static unsigned short getrpacketevent(tftp_packet_t *packet)
243
243
{
244
 
  return (packet->data[0] << 8) | packet->data[1];
 
244
  return (unsigned short)((packet->data[0] << 8) | packet->data[1]);
245
245
}
246
246
 
247
247
static unsigned short getrpacketblock(tftp_packet_t *packet)
248
248
{
249
 
  return (packet->data[2] << 8) | packet->data[3];
 
249
  return (unsigned short)((packet->data[2] << 8) | packet->data[3]);
250
250
}
251
251
 
252
252
static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
355
355
      }
356
356
    }
357
357
    /* This is the expected block.  Reset counters and ACK it. */
358
 
    state->block = rblock;
 
358
    state->block = (unsigned short)rblock;
359
359
    state->retries = 0;
360
360
    setpacketevent(&state->spacket, TFTP_EVENT_ACK);
361
361
    setpacketblock(&state->spacket, state->block);
575
575
  state->sockfd = state->conn->sock[FIRSTSOCKET];
576
576
  state->state = TFTP_STATE_START;
577
577
 
578
 
#ifdef WIN32
579
 
  /* AF_UNSPEC == 0 (from above calloc) doesn't work on Winsock */
580
 
 
581
 
  /* NOTE: this blatantly assumes IPv4. This should be fixed! */
582
 
  ((struct sockaddr_in*)&state->local_addr)->sin_family =
 
578
  ((struct sockaddr *)&state->local_addr)->sa_family =
583
579
    conn->ip_addr->ai_family;
584
 
#endif
585
580
 
586
581
  tftp_set_timeouts(state);
587
582