Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void * fetch(undefined4 *param_1)
- {
- uint16_t uVar1;
- int iVar2;
- ulong uVar3;
- char *__s;
- hostent *phVar4;
- hostent *phVar5;
- undefined8 uVar6;
- int *piVar7;
- void *__dest;
- long lVar8;
- undefined8 *puVar9;
- long in_FS_OFFSET;
- byte bVar10;
- uint16_t local_11c;
- char *local_118;
- char *local_110;
- char *local_108;
- undefined4 local_b8;
- undefined local_b4;
- char *local_b0;
- size_t local_a8;
- undefined8 local_a0;
- sa_family_t local_98;
- uint16_t uStack150;
- undefined4 uStack148;
- undefined8 uStack144;
- undefined8 uStack136;
- long local_10;
- bVar10 = 0;
- local_10 = *(long *)(in_FS_OFFSET + 0x28);
- local_b8 = *param_1;
- local_b4 = 1;
- local_b0 = (char *)0x0;
- local_a8 = 0;
- local_a0 = 0;
- local_118 = (char *)0x0;
- uVar3 = min((uint)*(undefined8 *)(param_1 + 4),7);
- iVar2 = strncmp("http://",*(char **)(param_1 + 2),(long)(int)uVar3);
- if (iVar2 == 0) {
- __s = (char *)(*(long *)(param_1 + 2) + 7);
- local_108 = strchrnul(__s,0x2f);
- if ((long)(local_108 + -(long)__s) < 0x101) {
- local_110 = strchr(__s,0x3a);
- if (local_108 <= local_110) {
- local_110 = (char *)0x0;
- }
- if (local_110 == (char *)0x0) {
- local_11c = 0x50;
- local_118 = strndup(__s,(size_t)(local_108 + -(long)__s));
- }
- else {
- local_118 = strndup(__s,(size_t)(local_110 + -(long)__s));
- __s = strndup(local_110 + 1,(size_t)(local_108 + -(long)(local_110 + 1)));
- if (__s == (char *)0x0) {
- /* WARNING: Subroutine does not return */
- __assert_fail("atstr","task/main.c",0x7f,"fetch");
- }
- iVar2 = atoi(__s);
- local_11c = (uint16_t)iVar2;
- if ((iVar2 < 0) || (0x10000 < iVar2)) {
- puts("invalid port");
- /* WARNING: Subroutine does not return */
- abort();
- }
- free(__s);
- }
- if (local_118 == (char *)0x0) {
- /* WARNING: Subroutine does not return */
- __assert_fail("domain","task/main.c",0x87,"fetch");
- }
- if (*local_108 == '\0') {
- local_108 = "/";
- }
- if (*local_108 != '/') {
- /* WARNING: Subroutine does not return */
- __assert_fail("path[0] == \'/\'","task/main.c",0x8d,"fetch");
- }
- uVar1 = htons(local_11c);
- phVar4 = gethostbyname2(local_118,10);
- lVar8 = 0x10;
- puVar9 = (undefined8 *)&local_98;
- while (lVar8 != 0) {
- lVar8 = lVar8 + -1;
- *puVar9 = 0;
- puVar9 = puVar9 + (ulong)bVar10 * 0x1ffffffffffffffe + 1;
- }
- if (phVar4 != (hostent *)0x0) {
- if (phVar4->h_addrtype != 10) {
- /* WARNING: Subroutine does not return */
- __assert_fail("hent6->h_addrtype == AF_INET6","task/main.c",0x95,"fetch");
- }
- local_98 = 10;
- uStack136 = *(undefined8 *)(*phVar4->h_addr_list + 1);
- uStack144 = *(undefined8 *)*phVar4->h_addr_list;
- uStack150 = uVar1;
- iVar2 = memcmp(&local_98 + 8,in6addr_loopback,0x10);
- if ((iVar2 == 0) || ((char)uStack144 == '\0')) {
- local_b0 = "localhost not allowed";
- goto LAB_00101de7;
- }
- }
- phVar5 = gethostbyname2(local_118,2);
- if (phVar5 != (hostent *)0x0) {
- if (phVar5->h_addrtype != 2) {
- /* WARNING: Subroutine does not return */
- __assert_fail("hent4->h_addrtype == AF_INET","task/main.c",0xa0,"fetch");
- }
- if ((**phVar5->h_addr_list == '\x7f') || (**phVar5->h_addr_list == '\0')) {
- local_b0 = "localhost not allowed";
- goto LAB_00101de7;
- }
- }
- if ((phVar4 != (hostent *)0x0) &&
- (uVar6 = make_request((sockaddr *)&local_98,0x80,local_118,local_108,&local_b0,
- (long *)&local_a8), (char)uVar6 != '\0')) goto LAB_00101e07;
- if (phVar5 == (hostent *)0x0) {
- piVar7 = __h_errno_location();
- local_b0 = hstrerror(*piVar7);
- }
- else {
- local_98 = 2;
- uStack148 = *(undefined4 *)*phVar5->h_addr_list;
- uStack150 = uVar1;
- uVar6 = make_request((sockaddr *)&local_98,0x80,local_118,local_108,&local_b0,
- (long *)&local_a8);
- if ((char)uVar6 != '\0') goto LAB_00101e07;
- }
- }
- else {
- local_b0 = "host too long";
- }
- }
- else {
- local_b0 = "not http";
- }
- LAB_00101de7:
- local_b4 = 0;
- local_a8 = strlen(local_b0);
- LAB_00101e07:
- free(local_118);
- __dest = calloc(1,0x20);
- memcpy(__dest,&local_b8,0x20);
- if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
- return __dest;
- }
- /* WARNING: Subroutine does not return */
- __stack_chk_fail();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement