mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 17:33:08 +00:00
fixed return code processing of stowSid(), and also added more
informative error messages.
This commit is contained in:
parent
ec94f6c12f
commit
397ea4279a
@ -107,11 +107,11 @@ int validateSid(const char *sid)
|
||||
{
|
||||
size_t n = strlen(sid);
|
||||
if (n != SID_STRLEN)
|
||||
return setReason("Invalid SID (strlen is %u, should be %u)", n, SID_STRLEN);
|
||||
return WHYF("Invalid SID (strlen is %u, should be %u)", n, SID_STRLEN);
|
||||
const char *s;
|
||||
for (s = sid; *s; ++s)
|
||||
if (hexvalue(*s) == -1)
|
||||
return -1;
|
||||
return WHY("SID contains non-hex character");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -119,8 +119,8 @@ int stowSid(unsigned char *packet, int ofs, const char *sid)
|
||||
{
|
||||
if (debug&DEBUG_PACKETFORMATS)
|
||||
printf("Stowing SID \"%s\"\n", sid);
|
||||
if (!validateSid(sid))
|
||||
return -1;
|
||||
if (validateSid(sid))
|
||||
return WHY("Invalid SID passed in");
|
||||
int i;
|
||||
for(i = 0; i != SID_SIZE; ++i) {
|
||||
packet[ofs] = hexvalue(sid[i<<1]) << 4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user