~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to slirp/tftp.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-07 06:20:34 UTC
  • mfrom: (1.1.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20090307062034-i3pead4mw653v2el
Tags: 0.10.0-1
[ Aurelien Jarno ]
* New upstream release:
  - Fix fr-be keyboard mapping (closes: bug#514462).
  - Fix stat64 structure on ppc-linux-user (closes: bug#470231).
  - Add a chroot option (closes: bug#415996).
  - Add evdev support (closes: bug#513210).
  - Fix loop on symlinks in user mode (closes: bug#297572).
  - Bump depends on openbios-sparc.
  - Depends on openbios-ppc.
  - Update 12_signal_powerpc_support.patch.
  - Update 21_net_soopts.patch.
  - Drop 44_socklen_t_check.patch (merged upstream).
  - Drop 49_null_check.patch (merged upstream).
  - Update 64_ppc_asm_constraints.patch.
  - Drop security/CVE-2008-0928-fedora.patch (merged upstream).
  - Drop security/CVE-2007-5730.patch (merged upstream).
* patches/80_stable-branch.patch: add patches from stable branch:
  - Fix race condition between signal handler/execution loop (closes:
    bug#474386, bug#501731).
* debian/copyright: update.
* Compile and install .dtb files:
  - debian/control: build-depends on device-tree-compiler.
  - debian/patches/81_compile_dtb.patch: new patch from upstream.
  - debian/rules: compile and install bamboo.dtb and mpc8544.dtb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 */
24
24
 
25
25
#include <slirp.h>
 
26
#include "qemu-common.h" // for pstrcpy
26
27
 
27
28
struct tftp_session {
28
29
    int in_use;
148
149
    m->m_data += sizeof(struct udpiphdr);
149
150
 
150
151
    tp->tp_op = htons(TFTP_OACK);
151
 
    n += sprintf(tp->x.tp_buf + n, "%s", key) + 1;
152
 
    n += sprintf(tp->x.tp_buf + n, "%u", value) + 1;
 
152
    n += snprintf((char *)tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
 
153
                  key) + 1;
 
154
    n += snprintf((char *)tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",
 
155
                  value) + 1;
153
156
 
154
157
    saddr.sin_addr = recv_tp->ip.ip_dst;
155
158
    saddr.sin_port = recv_tp->udp.uh_dport;
189
192
 
190
193
  tp->tp_op = htons(TFTP_ERROR);
191
194
  tp->x.tp_error.tp_error_code = htons(errorcode);
192
 
  strcpy(tp->x.tp_error.tp_msg, msg);
 
195
  pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg);
193
196
 
194
197
  saddr.sin_addr = recv_tp->ip.ip_dst;
195
198
  saddr.sin_port = recv_tp->udp.uh_dport;
324
327
  /* do sanity checks on the filename */
325
328
 
326
329
  if ((spt->filename[0] != '/')
327
 
      || (spt->filename[strlen(spt->filename) - 1] == '/')
328
 
      ||  strstr(spt->filename, "/../")) {
 
330
      || (spt->filename[strlen((char *)spt->filename) - 1] == '/')
 
331
      ||  strstr((char *)spt->filename, "/../")) {
329
332
      tftp_send_error(spt, 2, "Access violation", tp);
330
333
      return;
331
334
  }
352
355
  while (k < n) {
353
356
      const char *key, *value;
354
357
 
355
 
      key = src + k;
 
358
      key = (char *)src + k;
356
359
      k += strlen(key) + 1;
357
360
 
358
361
      if (k >= n) {
360
363
          return;
361
364
      }
362
365
 
363
 
      value = src + k;
 
366
      value = (char *)src + k;
364
367
      k += strlen(value) + 1;
365
368
 
366
369
      if (strcmp(key, "tsize") == 0) {