simplistic support for single-part yenc

master
leitner 22 years ago
parent b7154a5d3c
commit e108646f26

@ -192,8 +192,9 @@ invalidybegin:
continue; continue;
} }
l=filename-line+6; l=filename-line+6;
if (!(filename=strstr(line," part="))) goto invalidybegin; if (!(filename=strstr(line," part="))) {
if (filename[6+scan_ulong(filename+6,&part)] != ' ') goto invalidybegin; part=1;
} else if (filename[6+scan_ulong(filename+6,&part)] != ' ') goto invalidybegin;
if (part==1) reconstructed=0; if (part==1) reconstructed=0;
if (!(filename=strstr(line," size="))) goto invalidybegin; if (!(filename=strstr(line," size="))) goto invalidybegin;
if (filename[6+scan_ulong(filename+6,&totalsize)] != ' ') goto invalidybegin; if (filename[6+scan_ulong(filename+6,&totalsize)] != ' ') goto invalidybegin;
@ -227,9 +228,16 @@ invalidpart:
stralloc out; stralloc out;
char* tmp=strstr(line," pcrc32="); char* tmp=strstr(line," pcrc32=");
if (!tmp) goto invalidpart; if (tmp) {
if (!scan_xlong(tmp+8,&wantedcrc)) if (!scan_xlong(tmp+8,&wantedcrc))
goto invalidpart; goto invalidpart;
} else if (part==1) {
tmp=strstr(line," crc32=");
if (!tmp) goto invalidpart;
if (!scan_xlong(tmp+7,&wantedcrc))
goto invalidpart;
endoffset=totalsize;
} else goto invalidpart;
stralloc_init(&out); stralloc_init(&out);
stralloc_0(&yencpart); stralloc_0(&yencpart);
stralloc_ready(&out,yencpart.len); stralloc_ready(&out,yencpart.len);
@ -258,6 +266,7 @@ invalidpart:
buffer_puts(buffer_2,"warning: part "); buffer_puts(buffer_2,"warning: part ");
buffer_putulong(buffer_2,part); buffer_putulong(buffer_2,part);
buffer_putsflush(buffer_2," corrupt; reconstruction failed.\n"); buffer_putsflush(buffer_2," corrupt; reconstruction failed.\n");
buffer_put(&fileout,out.s,out.len);
} }
} }
stralloc_free(&out); stralloc_free(&out);

Loading…
Cancel
Save