Skip to content

Commit ad92c23

Browse files
committed
Address second round of review comments
- Fix decrypt lastLoopFlag to use payload size excluding salt+IV, preventing spurious EOF error when payload < MAX_LEN - Handle WAIT_FAILED/WAIT_ABANDONED in Windows checkStdin() - Catch TimeoutExpired in server-test.py cleanup, fall back to kill() - Also exit 77 when all individual tests are skipped (not just class) - Increase MAX_CLIENT_ARGS from 17 to 32 for worst-case arg expansion - Remove trailing whitespace on #undef lines in clu_header_main.h
1 parent 85be9ff commit ad92c23

6 files changed

Lines changed: 23 additions & 20 deletions

File tree

src/client/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,8 +2101,8 @@ int checkStdin(void)
21012101
}
21022102
else {
21032103
DWORD waitResult = WaitForSingleObject(stdinHandle, 0);
2104-
if (waitResult == WAIT_OBJECT_0) {
2105-
stop = 1; /* stdin has data or is closed */
2104+
if (waitResult != WAIT_TIMEOUT) {
2105+
stop = 1;
21062106
}
21072107
}
21082108
#else

src/client/clu_client_setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static const char sniFlag[] = "-S";
7272
int myoptind = 0;
7373
char* myoptarg = NULL;
7474

75-
#define MAX_CLIENT_ARGS 17
75+
#define MAX_CLIENT_ARGS 32
7676

7777
/* return WOLFCLU_SUCCESS on success */
7878
static int _addClientArg(const char** args, const char* in, int* idx)

src/crypto/clu_decrypt.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,13 @@ int wolfCLU_decrypt(int alg, char* mode, byte* pwdKey, byte* key, int size,
7777
length = (int)XFTELL(inFile);
7878
XFSEEK(inFile, 0, SEEK_SET);
7979

80-
/* if there is a remainder,
81-
* round up else no round
82-
*/
83-
if (length % MAX_LEN > 0) {
84-
lastLoopFlag = (length/MAX_LEN) + 1;
80+
/* Compute loop count from the encrypted payload size (excluding the
81+
* salt and IV that are read separately before the loop). */
82+
if ((length - saltAndIvSize) % MAX_LEN > 0) {
83+
lastLoopFlag = ((length - saltAndIvSize) / MAX_LEN) + 1;
8584
}
8685
else {
87-
lastLoopFlag = length/MAX_LEN;
86+
lastLoopFlag = (length - saltAndIvSize) / MAX_LEN;
8887
}
8988

9089
input = (byte*) XMALLOC(MAX_LEN, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);

tests/server/server-test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def test_server_client(self):
6363
f"s_client failed: {client.stderr}")
6464
finally:
6565
server.terminate()
66-
server.wait(timeout=5)
66+
try:
67+
server.wait(timeout=5)
68+
except subprocess.TimeoutExpired:
69+
server.kill()
70+
server.wait()
6771

6872

6973
if __name__ == "__main__":

tests/wolfclu_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ def test_main():
6767
result = prog.result
6868
if not result.wasSuccessful():
6969
sys.exit(1)
70-
if result.testsRun == 0:
70+
if result.testsRun == 0 or len(result.skipped) == result.testsRun:
7171
sys.exit(77)
7272
sys.exit(0)

wolfclu/clu_header_main.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ extern "C" {
4343
#endif
4444
#endif
4545

46-
#undef CRL_REASON_UNSPECIFIED
47-
#undef CRL_REASON_KEY_COMPROMISE
48-
#undef CRL_REASON_CA_COMPROMISE
49-
#undef CRL_REASON_AFFILIATION_CHANGED
50-
#undef CRL_REASON_SUPERSEDED
46+
#undef CRL_REASON_UNSPECIFIED
47+
#undef CRL_REASON_KEY_COMPROMISE
48+
#undef CRL_REASON_CA_COMPROMISE
49+
#undef CRL_REASON_AFFILIATION_CHANGED
50+
#undef CRL_REASON_SUPERSEDED
5151
#undef CRL_REASON_CESSATION_OF_OPERATION
52-
#undef CRL_REASON_CERTIFICATE_HOLD
53-
#undef CRL_REASON_REMOVE_FROM_CRL
54-
#undef CRL_REASON_PRIVILEGE_WITHDRAWN
55-
#undef CRL_REASON_AA_COMPROMISE
52+
#undef CRL_REASON_CERTIFICATE_HOLD
53+
#undef CRL_REASON_REMOVE_FROM_CRL
54+
#undef CRL_REASON_PRIVILEGE_WITHDRAWN
55+
#undef CRL_REASON_AA_COMPROMISE
5656

5757

5858
/* wolfssl includes */

0 commit comments

Comments
 (0)