Loading src/secureid.c +3 −3 Original line number Diff line number Diff line Loading @@ -119,9 +119,9 @@ int SIDcpy(struct SID *dest,struct SID *src){ int written=0; for (int ii = 0; ii < (int)src->SubAuthorityCount - 1; ++ii) { memcpy32(dest->SubAuthority+(src->SubAuthorityCount * sizeof(uint32_t)), src->SubAuthority[1]+(src->SubAuthorityCount * sizeof(uint32_t)), for (int ii = 0; ii < src->SubAuthorityCount/sizeof(uint32_t)-1; ++ii) { memcpy32(dest->SubAuthority[ii]+(src->SubAuthorityCount * sizeof(uint32_t)), src->SubAuthority[ii]+(src->SubAuthorityCount * sizeof(uint32_t)), sizeof(uint32_t) ); written+=sizeof(uint32_t); Loading test/CMakeLists.txt +6 −0 Original line number Diff line number Diff line Loading @@ -3,3 +3,9 @@ target_link_libraries(parse secureid) add_test(NAME parse COMMAND parse "${CMAKE_SOURCE_DIR}/test/sid.txt") set_tests_properties(parse PROPERTIES WILL_FAIL TRUE) add_executable(copy copy) target_link_libraries(copy secureid) add_test(NAME copy COMMAND copy "${CMAKE_SOURCE_DIR}/test/sid.txt") set_tests_properties(copy PROPERTIES WILL_FAIL TRUE) test/copy.c 0 → 100644 +89 −0 Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2023, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include "stdio.h" #include "string.h" #include "secureid.h" int main(int argc, char *argv[]){ int read=0; if(argc!=2){ printf("no file path argument append !"); return -1; } FILE *list; list=fopen(argv[1],"r"); if(list==0){ printf("cannot open file !"); return -1; } int failed=0; while(read==0){ char line[512],out[512]; int spos=0,written=0;; for(spos=fgetc(list); spos!='\n'; spos=fgetc(list)){ if(written > 511){ printf("line too long aborting"); failed=-1; } if(feof(list)){ read=-1; break; } line[written++]=spos; } if(written==0) return 0; line[written]='\0'; struct SID *sid,*sid2; initSID(&sid); initSID(&sid2); int ret=parseSID(sid,line,written); if(ret!=-1){ SIDcpy(sid2,sid); destroySID(sid); printSID(sid2,out,512); } destroySID(sid2); if(ret!=-1 && strcmp(line,out)==0){ printf("Success: %s \n",out); continue; } printf("Failed: %s \n",line); failed = -1; } return failed; } Loading
src/secureid.c +3 −3 Original line number Diff line number Diff line Loading @@ -119,9 +119,9 @@ int SIDcpy(struct SID *dest,struct SID *src){ int written=0; for (int ii = 0; ii < (int)src->SubAuthorityCount - 1; ++ii) { memcpy32(dest->SubAuthority+(src->SubAuthorityCount * sizeof(uint32_t)), src->SubAuthority[1]+(src->SubAuthorityCount * sizeof(uint32_t)), for (int ii = 0; ii < src->SubAuthorityCount/sizeof(uint32_t)-1; ++ii) { memcpy32(dest->SubAuthority[ii]+(src->SubAuthorityCount * sizeof(uint32_t)), src->SubAuthority[ii]+(src->SubAuthorityCount * sizeof(uint32_t)), sizeof(uint32_t) ); written+=sizeof(uint32_t); Loading
test/CMakeLists.txt +6 −0 Original line number Diff line number Diff line Loading @@ -3,3 +3,9 @@ target_link_libraries(parse secureid) add_test(NAME parse COMMAND parse "${CMAKE_SOURCE_DIR}/test/sid.txt") set_tests_properties(parse PROPERTIES WILL_FAIL TRUE) add_executable(copy copy) target_link_libraries(copy secureid) add_test(NAME copy COMMAND copy "${CMAKE_SOURCE_DIR}/test/sid.txt") set_tests_properties(copy PROPERTIES WILL_FAIL TRUE)
test/copy.c 0 → 100644 +89 −0 Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2023, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include "stdio.h" #include "string.h" #include "secureid.h" int main(int argc, char *argv[]){ int read=0; if(argc!=2){ printf("no file path argument append !"); return -1; } FILE *list; list=fopen(argv[1],"r"); if(list==0){ printf("cannot open file !"); return -1; } int failed=0; while(read==0){ char line[512],out[512]; int spos=0,written=0;; for(spos=fgetc(list); spos!='\n'; spos=fgetc(list)){ if(written > 511){ printf("line too long aborting"); failed=-1; } if(feof(list)){ read=-1; break; } line[written++]=spos; } if(written==0) return 0; line[written]='\0'; struct SID *sid,*sid2; initSID(&sid); initSID(&sid2); int ret=parseSID(sid,line,written); if(ret!=-1){ SIDcpy(sid2,sid); destroySID(sid); printSID(sid2,out,512); } destroySID(sid2); if(ret!=-1 && strcmp(line,out)==0){ printf("Success: %s \n",out); continue; } printf("Failed: %s \n",line); failed = -1; } return failed; }