Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ int strcasecmp(const char *s1, const char *s2)
while (!diff && *s1) {
diff = (int)*s1 - (int)*s2;

if ((diff == 'A' - 'a') || (diff == 'a' - 'A'))
if (((diff == 'A' - 'a') || (diff == 'a' - 'A')) &&
(isalpha((unsigned char)*s1) && isalpha((unsigned char)*s2)))
Comment thread
danielinux marked this conversation as resolved.
diff = 0;

s1++;
Expand All @@ -142,12 +143,13 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
while (!diff && *s1) {
diff = (int)*s1 - (int)*s2;

if ((diff == 'A' - 'a') || (diff == 'a' - 'A'))
if (((diff == 'A' - 'a') || (diff == 'a' - 'A')) &&
(isalpha((unsigned char)*s1) && isalpha((unsigned char)*s2)))
Comment thread
danielinux marked this conversation as resolved.
diff = 0;

s1++;
s2++;
if (++i > n)
if (++i >= n)
break;
}
return diff;
Expand All @@ -156,16 +158,13 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
#if !defined(__CCRX__) /* Renesas CCRX */
char *strncat(char *dest, const char *src, size_t n)
{
size_t i = 0;
size_t i;
size_t j = strlen(dest);

for (i = 0; i < strlen(src); i++) {
if (j >= (n - 1)) {
break;
}
dest[j++] = src[i];
for (i = 0; i < n && src[i] != '\0'; i++) {
dest[j + i] = src[i];
}
dest[j] = '\0';
dest[j + i] = '\0';

return dest;
}
Expand Down
4 changes: 3 additions & 1 deletion tools/fdt-parser/fdt-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ int main(int argc, char *argv[])
if (ret == 0) {
char outfilename[PATH_MAX];
strncpy(outfilename, filename, sizeof(outfilename)-1);
strncat(outfilename, ".out", sizeof(outfilename)-1);
outfilename[sizeof(outfilename) - 1] = '\0';
strncat(outfilename, ".out",
sizeof(outfilename) - strlen(outfilename) - 1);

/* save updated binary file */
write_bin(outfilename, image, imageSz + UNIT_TEST_GROW_SIZE);
Expand Down
12 changes: 8 additions & 4 deletions tools/unit-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ LDFLAGS+=-ftest-coverage



TESTS:=unit-parser unit-extflash unit-spi-flash unit-aes128 unit-aes256 \
unit-chacha20 unit-pci unit-mock-state unit-sectorflags unit-image \
unit-nvm unit-nvm-flagshome unit-enc-nvm unit-enc-nvm-flagshome \
unit-delta unit-update-flash unit-update-ram unit-pkcs11_store
TESTS:=unit-parser unit-extflash unit-string unit-spi-flash unit-aes128 \
unit-aes256 unit-chacha20 unit-pci unit-mock-state unit-sectorflags \
unit-image unit-nvm unit-nvm-flagshome unit-enc-nvm \
unit-enc-nvm-flagshome unit-delta unit-update-flash unit-update-ram \
unit-pkcs11_store

all: $(TESTS)

Expand Down Expand Up @@ -94,6 +95,9 @@ unit-extflash: ../../include/target.h unit-extflash.c
unit-spi-flash: ../../include/target.h unit-spi-flash.c
gcc -o $@ $^ $(CFLAGS) $(LDFLAGS)

unit-string: ../../include/target.h unit-string.c
gcc -o $@ $^ $(CFLAGS) -DDEBUG_UART -DPRINTF_ENABLED $(LDFLAGS)

unit-aes128: ../../include/target.h unit-extflash.c
gcc -o $@ $^ $(CFLAGS) $(LDFLAGS)

Expand Down
Loading