summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio/b_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio/b_dump.c')
-rw-r--r--src/lib/libcrypto/bio/b_dump.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c
index 8397cfab6a..983604fb49 100644
--- a/src/lib/libcrypto/bio/b_dump.c
+++ b/src/lib/libcrypto/bio/b_dump.c
@@ -104,38 +104,41 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
104 for(i=0;i<rows;i++) 104 for(i=0;i<rows;i++)
105 { 105 {
106 buf[0]='\0'; /* start with empty string */ 106 buf[0]='\0'; /* start with empty string */
107 strcpy(buf,str); 107 strlcpy(buf,str,sizeof buf);
108 sprintf(tmp,"%04x - ",i*dump_width); 108 snprintf(tmp,sizeof tmp,"%04x - ",i*dump_width);
109 strcat(buf,tmp); 109 strlcat(buf,tmp,sizeof buf);
110 for(j=0;j<dump_width;j++) 110 for(j=0;j<dump_width;j++)
111 { 111 {
112 if (((i*dump_width)+j)>=len) 112 if (((i*dump_width)+j)>=len)
113 { 113 {
114 strcat(buf," "); 114 strlcat(buf," ",sizeof buf);
115 } 115 }
116 else 116 else
117 { 117 {
118 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; 118 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
119 sprintf(tmp,"%02x%c",ch,j==7?'-':' '); 119 snprintf(tmp,sizeof tmp,"%02x%c",ch,
120 strcat(buf,tmp); 120 j==7?'-':' ');
121 strlcat(buf,tmp,sizeof buf);
121 } 122 }
122 } 123 }
123 strcat(buf," "); 124 strlcat(buf," ",sizeof buf);
124 for(j=0;j<dump_width;j++) 125 for(j=0;j<dump_width;j++)
125 { 126 {
126 if (((i*dump_width)+j)>=len) 127 if (((i*dump_width)+j)>=len)
127 break; 128 break;
128 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; 129 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
129#ifndef CHARSET_EBCDIC 130#ifndef CHARSET_EBCDIC
130 sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); 131 snprintf(tmp,sizeof tmp,"%c",
132 ((ch>=' ')&&(ch<='~'))?ch:'.');
131#else 133#else
132 sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) 134 snprintf(tmp,sizeof tmp,"%c",
133 ? os_toebcdic[ch] 135 ((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
134 : '.'); 136 ? os_toebcdic[ch]
137 : '.');
135#endif 138#endif
136 strcat(buf,tmp); 139 strlcat(buf,tmp,sizeof buf);
137 } 140 }
138 strcat(buf,"\n"); 141 strlcat(buf,"\n",sizeof buf);
139 /* if this is the last call then update the ddt_dump thing so that 142 /* if this is the last call then update the ddt_dump thing so that
140 * we will move the selection point in the debug window 143 * we will move the selection point in the debug window
141 */ 144 */
@@ -144,7 +147,8 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
144#ifdef TRUNCATE 147#ifdef TRUNCATE
145 if (trunc > 0) 148 if (trunc > 0)
146 { 149 {
147 sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc); 150 snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str,
151 len+trunc);
148 ret+=BIO_write(bio,(char *)buf,strlen(buf)); 152 ret+=BIO_write(bio,(char *)buf,strlen(buf));
149 } 153 }
150#endif 154#endif