fixup for nul termination of debug output

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38955 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2015-08-30 10:25:52 +00:00
parent afa642aa1f
commit d2dd33f3b1
2 changed files with 22 additions and 20 deletions

View file

@ -231,7 +231,7 @@ static Class sslClass = 0;
static void
debugRead(GSHTTPURLHandle *handle, NSData *data)
{
NSUInteger len = [data length];
int len = (int)[data length];
const uint8_t *ptr = (const uint8_t*)[data bytes];
uint8_t *hex;
NSUInteger hl;
@ -240,28 +240,28 @@ debugRead(GSHTTPURLHandle *handle, NSData *data)
hl = ((len + 2) / 3) * 4;
hex = malloc(hl + 1);
hex[hl] = '\0';
GSPrivateEncodeBase64(ptr, len, hex);
GSPrivateEncodeBase64(ptr, (NSUInteger)len, hex);
for (pos = 0; pos < len; pos++)
{
if (0 == ptr[pos])
{
char *esc = [data escapedRepresentation: 0];
NSLog(@"Read for %p of %u bytes (escaped) - '%s'\n<[%*.*s]>",
handle, (unsigned)len, esc, hex);
NSLog(@"Read for %p of %d bytes (escaped) - '%s'\n<[%s]>",
handle, len, esc, hex);
free(esc);
free(hex);
return;
}
}
NSLog(@"Read for %p of %d bytes - '%s'\n<[%*.*s]>",
handle, (unsigned)len, ptr, hex);
NSLog(@"Read for %p of %d bytes - '%*.*s'\n<[%s]>",
handle, len, len, len, ptr, hex);
free(hex);
}
static void
debugWrite(GSHTTPURLHandle *handle, NSData *data)
{
NSUInteger len = [data length];
int len = (int)[data length];
const uint8_t *ptr = (const uint8_t*)[data bytes];
uint8_t *hex;
NSUInteger hl;
@ -270,22 +270,22 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
hl = ((len + 2) / 3) * 4;
hex = malloc(hl + 1);
hex[hl] = '\0';
GSPrivateEncodeBase64(ptr, len, hex);
GSPrivateEncodeBase64(ptr, (NSUInteger)len, hex);
for (pos = 0; pos < len; pos++)
{
if (0 == ptr[pos])
{
char *esc = [data escapedRepresentation: 0];
NSLog(@"Write for %p of %u bytes (escaped) - '%s'\n<[%s]>",
handle, (unsigned)len, esc, hex);
NSLog(@"Write for %p of %d bytes (escaped) - '%s'\n<[%s]>",
handle, len, esc, hex);
free(esc);
free(hex);
return;
}
}
NSLog(@"Write for %p of %d bytes - '%s'\n<[%s]>",
handle, (unsigned)len, ptr, hex);
NSLog(@"Write for %p of %d bytes - '%*.*s'\n<[%s]>",
handle, len, len, len, ptr, hex);
free(hex);
}

View file

@ -69,7 +69,7 @@ zfree(void *opaque, void *mem)
#endif
static void
debugRead(id handle, unsigned len, const unsigned char *ptr)
debugRead(id handle, int len, const unsigned char *ptr)
{
int pos;
uint8_t *hex;
@ -78,7 +78,7 @@ debugRead(id handle, unsigned len, const unsigned char *ptr)
hl = ((len + 2) / 3) * 4;
hex = malloc(hl + 1);
hex[hl] = '\0';
GSPrivateEncodeBase64(ptr, len, hex);
GSPrivateEncodeBase64(ptr, (NSUInteger)len, hex);
for (pos = 0; pos < len; pos++)
{
@ -92,7 +92,7 @@ debugRead(id handle, unsigned len, const unsigned char *ptr)
freeWhenDone: NO];
esc = [data escapedRepresentation: 0];
NSLog(@"Read for %p of %u bytes (escaped) - '%s'\n<[%s]>",
NSLog(@"Read for %p of %d bytes (escaped) - '%s'\n<[%s]>",
handle, len, esc, hex);
free(esc);
RELEASE(data);
@ -100,11 +100,12 @@ debugRead(id handle, unsigned len, const unsigned char *ptr)
return;
}
}
NSLog(@"Read for %p of %d bytes - '%s'\n<[%s]>", handle, len, ptr, hex);
NSLog(@"Read for %p of %d bytes - '%*.*s'\n<[%s]>",
handle, len, len, len, ptr, hex);
free(hex);
}
static void
debugWrite(id handle, unsigned len, const unsigned char *ptr)
debugWrite(id handle, int len, const unsigned char *ptr)
{
int pos;
uint8_t *hex;
@ -113,7 +114,7 @@ debugWrite(id handle, unsigned len, const unsigned char *ptr)
hl = ((len + 2) / 3) * 4;
hex = malloc(hl + 1);
hex[hl] = '\0';
GSPrivateEncodeBase64(ptr, len, hex);
GSPrivateEncodeBase64(ptr, (NSUInteger)len, hex);
for (pos = 0; pos < len; pos++)
{
@ -126,7 +127,7 @@ debugWrite(id handle, unsigned len, const unsigned char *ptr)
length: len
freeWhenDone: NO];
esc = [data escapedRepresentation: 0];
NSLog(@"Write for %p of %u bytes (escaped) - '%s'\n<[%s]>",
NSLog(@"Write for %p of %d bytes (escaped) - '%s'\n<[%s]>",
handle, len, esc, hex);
free(esc);
RELEASE(data);
@ -134,7 +135,8 @@ debugWrite(id handle, unsigned len, const unsigned char *ptr)
return;
}
}
NSLog(@"Write for %p of %d bytes - '%s'\n<[%s]>", handle, len, ptr, hex);
NSLog(@"Write for %p of %d bytes - '%*.*s'\n<[%s]>",
handle, len, len, len, ptr, hex);
free(hex);
}