aboutsummaryrefslogtreecommitdiffstats
path: root/core/pxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/pxe.c')
-rw-r--r--core/pxe.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/core/pxe.c b/core/pxe.c
index ff825e01..eec23fdf 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -1732,13 +1732,13 @@ int fill_tail(char *dst)
p += strlen(mode) + 1;
strcpy(p, tsize_str);
- p += tsize_len;
+ p += strlen(tsize_str) + 1;
- strcpy(p, blksize_str);
- p += blksize_len;
-
strcpy(p, "0");
p += 2;
+
+ strcpy(p, blksize_str);
+ p += strlen(blksize_str) + 1;
strcpy(p, asciidec);
p += strlen(asciidec) + 1;
@@ -1804,11 +1804,11 @@ void searchdir_c(com32sys_t *regs)
uint8_t timeout;
uint16_t oldtime;
uint16_t tid;
- uint16_t *data_ptr;
uint16_t opcode;
uint16_t blk_num;
uint32_t ip;
uint32_t filesize;
+ uint32_t *data_ptr;
init_options();
allocate_socket(regs);
@@ -1836,7 +1836,7 @@ void searchdir_c(com32sys_t *regs)
}
strcpy(buf, p); /* Copy the filename */
- buf += strlen(p);
+ buf += strlen(p) + 1; /* advance the pointer, null char included */
#if GPXE
if (is_gpxe(packet_buf + 2)) {
@@ -1845,6 +1845,7 @@ void searchdir_c(com32sys_t *regs)
fo->filename[1] = regs->ds;
err = pxe_call(PXENV_FILE_OPEN, fo);
if (err) {
+ regs->esi.w[0] = OFFS_WRT(file, 0);
free_socket(regs);
regs->eflags.l |= EFLAGS_ZF;
return;
@@ -1988,9 +1989,10 @@ void searchdir_c(com32sys_t *regs)
goto done_pkt;
dst = src = options;
- while (*src) {
+ while (buffersize--) {
+ if (*src == 0)
+ break; /* found a final null */
*dst++ = *src++ | 0x20;
- buffersize--;
if (!buffersize)
goto done_pkt; /* found no final null */
}
@@ -2010,21 +2012,18 @@ void searchdir_c(com32sys_t *regs)
goto err_reply; /* Non-negotitated option returned, no idea what it means ...*/
p += tftp_opt->str_len;
- buffersize -= tftp_opt->str_len;
-
+
/* get the address of the filed that we want to write on */
- data_ptr = (uint16_t *)((char *)file + tftp_opt->offset);
+ data_ptr = (uint32_t *)((char *)file + tftp_opt->offset);
+ *data_ptr = 0;
/* do convert a number-string to decimal number, just like atoi */
- while (*p) {
+ while (buffersize--) {
+ if (*p == 0)
+ break; /* found a final null */
if (*p > '9')
goto err_reply; /* Not a decimal digit */
- *data_ptr = *data_ptr * 10 + *p - '0';
-
- buffersize --;
- if (!buffersize)
- goto done_pkt;
- p++;
+ *data_ptr = *data_ptr * 10 + *p++ - '0';
}
}while (buffersize);
@@ -2043,7 +2042,8 @@ void searchdir_c(com32sys_t *regs)
}
done_pkt:
- regs->eax.l = file->tftp_filesize;
+ regs->eax.l = file->tftp_filesize;
+ regs->esi.w[0] = OFFS_WRT(file, 0);
got_file:
regs->eflags.l &= ~EFLAGS_ZF;
if (!file->tftp_filesize) {