this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1217 from asiekierka/3ds-fixes

n3ds: fix crash in async net_httpc access, close #1200

authored by

Vadim Grigoruk and committed by
GitHub
d70303c0 73d3be79

+7 -211
-9
CMakeLists.txt
··· 69 69 set(BUILD_SDL off) 70 70 # disable CURL linking - use HTTPC instead 71 71 set(DISABLE_NETWORKING TRUE) 72 - option(N3DS_BUILD_CIA "Build .cia variant - requires bannertool and makerom" FALSE) 73 72 endif() 74 73 75 74 if (BAREMETALPI) ··· 959 958 960 959 target_link_directories(${TIC80_OUTPUT}_n3ds PRIVATE ${DEVKITPRO}/libctru/lib) 961 960 target_link_libraries(${TIC80_OUTPUT}_n3ds ${TIC80_OUTPUT}lib png citro3d) 962 - 963 - if (N3DS_BUILD_CIA) 964 - add_custom_command(TARGET tic80_n3ds 965 - POST_BUILD 966 - COMMAND ${CMAKE_SOURCE_DIR}/build/n3ds/elf_to_cia.sh 967 - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build 968 - ) 969 - endif() 970 961 971 962 add_custom_command(TARGET tic80_n3ds 972 963 POST_BUILD
+2 -8
build/n3ds/README.md
··· 9 9 * 3ds-pkg-config 10 10 * 3ds-zlib 11 11 12 - If you'd like to build a .CIA archive in addition to .3DSX, the following tools must be added to your PATH: 13 - 14 - * bannertool 15 - * makerom 16 - 17 12 ## Building instructions 18 13 19 14 ``` 20 15 cd build 21 - cmake .. -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE -DN3DS_BUILD_CIA=? 22 - cmake .. -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE -DN3DS_BUILD_CIA=? # must be run twice due to bug 16 + cmake .. -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE 23 17 make 24 18 ``` 25 19 26 - You should now be able to find `tic80.3dsx` (and `tic80.cia`, if you enabled the CIA build option) in build/bin. 20 + You should now be able to find `tic80.3dsx` in build/bin.
-6
build/n3ds/elf_to_cia.sh
··· 1 - #!/bin/sh 2 - ${DEVKITARM}/bin/arm-none-eabi-strip -o tic80_cia.elf bin/tic80_n3ds 3 - bannertool makebanner -i ../src/system/n3ds/cia/banner.png -a ../src/system/n3ds/cia/sound.wav -o tic80_cia.bnr 4 - bannertool makesmdh -s "TIC-80" -l "TIC-80 tiny computer" -p "nesbox" -i ../src/system/n3ds/icon.png -o tic80_cia.smdh -r regionfree 5 - echo "[CIA] Building binary" 6 - makerom -f cia -elf tic80_cia.elf -icon tic80_cia.smdh -banner tic80_cia.bnr -desc app:4 -v -o bin/tic80.cia -target t -exefslogo -rsf ../src/system/n3ds/cia/build.rsf
src/system/n3ds/cia/banner.png

This is a binary file and will not be displayed.

-183
src/system/n3ds/cia/build.rsf
··· 1 - BasicInfo: 2 - Title : "TIC-80" 3 - ProductCode : "CTR-P-TC80" 4 - ContentType : Application 5 - Logo : Homebrew 6 - 7 - RomFs: 8 - RootPath : ../src/system/n3ds/romfs 9 - 10 - TitleInfo: 11 - Category : Application 12 - UniqueId : 0x71C80 13 - 14 - Option: 15 - UseOnSD : true # true if App is to be installed to SD 16 - FreeProductCode : true # Removes limitations on ProductCode 17 - MediaFootPadding : false # If true CCI files are created with padding 18 - EnableCrypt : false # Enables encryption for NCCH and CIA 19 - EnableCompress : true # Compresses exefs code 20 - 21 - SystemControlInfo: 22 - SaveDataSize: 0KB 23 - RemasterVersion: 0 24 - StackSize: 0x40000 25 - 26 - # DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely) 27 - 28 - AccessControlInfo: 29 - UseExtSaveData : false 30 - 31 - FileSystemAccess: 32 - - DirectSdmc 33 - - DirectSdmcWrite 34 - 35 - IdealProcessor : 0 36 - AffinityMask : 1 37 - 38 - Priority : 16 39 - 40 - MaxCpu : 0 41 - DisableDebug : true 42 - EnableForceDebug : false 43 - CanWriteSharedPage : false 44 - CanUsePrivilegedPriority : false 45 - CanUseNonAlphabetAndNumber : false 46 - PermitMainFunctionArgument : false 47 - CanShareDeviceMemory : false 48 - RunnableOnSleep : false 49 - SpecialMemoryArrange : false 50 - CoreVersion : 2 51 - DescVersion : 2 52 - 53 - ReleaseKernelMajor : "02" 54 - ReleaseKernelMinor : "33" 55 - MemoryType : Application 56 - HandleTableSize: 512 57 - 58 - SystemMode : 64MB 59 - SystemModeExt : 124MB # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode 60 - CpuSpeed : 804MHz # 268MHz(Default)/804MHz 61 - EnableL2Cache : true # false(default)/true 62 - CanAccessCore2 : true 63 - 64 - IORegisterMapping: 65 - - 1ff00000-1ff7ffff 66 - MemoryMapping: 67 - - 1f000000-1f5fffff:r 68 - SystemCallAccess: 69 - ArbitrateAddress: 34 70 - Break: 60 71 - CancelTimer: 28 72 - ClearEvent: 25 73 - ClearTimer: 29 74 - CloseHandle: 35 75 - ConnectToPort: 45 76 - ControlMemory: 1 77 - CreateAddressArbiter: 33 78 - CreateEvent: 23 79 - CreateMemoryBlock: 30 80 - CreateMutex: 19 81 - CreateSemaphore: 21 82 - CreateThread: 8 83 - CreateTimer: 26 84 - DuplicateHandle: 39 85 - ExitProcess: 3 86 - ExitThread: 9 87 - GetCurrentProcessorNumber: 17 88 - GetHandleInfo: 41 89 - GetProcessId: 53 90 - GetProcessIdOfThread: 54 91 - GetProcessIdealProcessor: 6 92 - GetProcessInfo: 43 93 - GetResourceLimit: 56 94 - GetResourceLimitCurrentValues: 58 95 - GetResourceLimitLimitValues: 57 96 - GetSystemInfo: 42 97 - GetSystemTick: 40 98 - GetThreadContext: 59 99 - GetThreadId: 55 100 - GetThreadIdealProcessor: 15 101 - GetThreadInfo: 44 102 - GetThreadPriority: 11 103 - MapMemoryBlock: 31 104 - OutputDebugString: 61 105 - QueryMemory: 2 106 - ReleaseMutex: 20 107 - ReleaseSemaphore: 22 108 - SendSyncRequest1: 46 109 - SendSyncRequest2: 47 110 - SendSyncRequest3: 48 111 - SendSyncRequest4: 49 112 - SendSyncRequest: 50 113 - SetThreadPriority: 12 114 - SetTimer: 27 115 - SignalEvent: 24 116 - SleepThread: 10 117 - UnmapMemoryBlock: 32 118 - WaitSynchronization1: 36 119 - WaitSynchronizationN: 37 120 - InterruptNumbers: 121 - ServiceAccessControl: 122 - - APT:U 123 - - $hioFIO 124 - - $hostio0 125 - - $hostio1 126 - - ac:u 127 - - boss:U 128 - - cam:u 129 - - ir:rst 130 - - cfg:u 131 - - dlp:FKCL 132 - - dlp:SRVR 133 - - dsp::DSP 134 - - ssl:C 135 - - fs:USER 136 - - gsp::Gpu 137 - - hid:USER 138 - - http:C 139 - - mic:u 140 - - ndm:u 141 - - news:s 142 - - nwm::UDS 143 - - ptm:u 144 - - pxi:dev 145 - - soc:U 146 - - gsp::Lcd 147 - - y2r:u 148 - - ldr:ro 149 - - ir:USER 150 - - ir:u 151 - 152 - SystemControlInfo: 153 - Dependency: 154 - ac: 0x0004013000002402L 155 - am: 0x0004013000001502L 156 - boss: 0x0004013000003402L 157 - camera: 0x0004013000001602L 158 - cecd: 0x0004013000002602L 159 - cfg: 0x0004013000001702L 160 - codec: 0x0004013000001802L 161 - csnd: 0x0004013000002702L 162 - dlp: 0x0004013000002802L 163 - dsp: 0x0004013000001a02L 164 - friends: 0x0004013000003202L 165 - gpio: 0x0004013000001b02L 166 - gsp: 0x0004013000001c02L 167 - hid: 0x0004013000001d02L 168 - http: 0x0004013000002902L 169 - i2c: 0x0004013000001e02L 170 - ir: 0x0004013000003302L 171 - mcu: 0x0004013000001f02L 172 - mic: 0x0004013000002002L 173 - ndm: 0x0004013000002b02L 174 - news: 0x0004013000003502L 175 - nim: 0x0004013000002c02L 176 - nwm: 0x0004013000002d02L 177 - pdn: 0x0004013000002102L 178 - ps: 0x0004013000003102L 179 - ptm: 0x0004013000002202L 180 - ro: 0x0004013000003702L 181 - socket: 0x0004013000002e02L 182 - spi: 0x0004013000002302L 183 - ssl: 0x0004013000002f02L
src/system/n3ds/cia/sound.wav

This is a binary file and will not be displayed.

+5 -5
src/system/n3ds/net_httpc.c
··· 111 111 } 112 112 113 113 if ((status_code >= 301 && status_code <= 303) || (status_code >= 307 && status_code <= 308)) { 114 - if (httpcGetResponseHeader(&ctx->httpc, "Location", ctx->url, TICNAME_MAX)) { 114 + if (httpcGetResponseHeader(&ctx->httpc, "Location", ctx->url, TICNAME_MAX - 1)) { 115 115 status_code = -4; 116 116 break; 117 117 } ··· 184 184 185 185 static void n3ds_net_get_thread(net_ctx *ctx) { 186 186 n3ds_net_execute(ctx, false); 187 - 187 + 188 188 if (ctx->buffer != NULL) { 189 189 free(ctx->buffer); 190 190 } ··· 192 192 } 193 193 194 194 static void n3ds_net_apply_url(net_ctx *ctx, const char *url) { 195 - strncpy(ctx->url, TIC_WEBSITE, TICNAME_MAX); 195 + strncpy(ctx->url, TIC_WEBSITE, TICNAME_MAX - 1); 196 196 strncat(ctx->url, url, TICNAME_MAX - 1); 197 197 } 198 198 ··· 201 201 net_ctx *ctx; 202 202 203 203 ctx = malloc(sizeof(net_ctx)); 204 - memset(&ctx, 0, sizeof(net_ctx)); 204 + memset(ctx, 0, sizeof(net_ctx)); 205 205 206 206 n3ds_net_apply_url(ctx, url); 207 207 ctx->net = net; ··· 224 224 *size = ctx.size; 225 225 } 226 226 return ctx.buffer; 227 - } 227 + }