summaryrefslogtreecommitdiffhomepage
path: root/src/archive
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-04-27 18:10:12 +0000
committermidipix <writeonce@midipix.org>2024-04-27 20:21:10 +0000
commit94cf00515f7abf57abafb091a64a32cda2fab7c6 (patch)
tree8ee321b2eae50b2a7d8cc5dbcdeae7345ac8a6bc /src/archive
parent6a74673f967c1b146000c8a47cfc094293f6db72 (diff)
downloadmdso-94cf00515f7abf57abafb091a64a32cda2fab7c6.tar.bz2
mdso-94cf00515f7abf57abafb091a64a32cda2fab7c6.tar.xz
mdso_argen_common_hdr(): eliminate the use of sprintf().
Diffstat (limited to 'src/archive')
-rw-r--r--src/archive/mdso_argen_common.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/archive/mdso_argen_common.c b/src/archive/mdso_argen_common.c
index c006bf7..2d2f3c5 100644
--- a/src/archive/mdso_argen_common.c
+++ b/src/archive/mdso_argen_common.c
@@ -11,16 +11,31 @@
#include <sys/mman.h>
#include <mdso/mdso.h>
+#include "mdso_object_impl.h"
#include "mdso_errinfo_impl.h"
#include "perk_structs.h"
+static void mdso_obj_write_objname(char * ch, off_t objidx)
+{
+ ch[0] = 's';
+
+ ch[6] = (objidx % 10) + '0'; objidx /= 10;
+ ch[5] = (objidx % 10) + '0'; objidx /= 10;
+ ch[4] = (objidx % 10) + '0'; objidx /= 10;
+ ch[3] = (objidx % 10) + '0'; objidx /= 10;
+ ch[2] = (objidx % 10) + '0'; objidx /= 10;
+ ch[1] = (objidx % 10) + '0'; objidx /= 10;
+
+ ch[7] = '.';
+ ch[8] = 'o';
+}
+
static void mdso_argen_common_hdr(
struct pe_raw_archive_common_hdr * arhdr,
char * file_id,
size_t size)
{
size_t slen;
- char sbuf[10];
memset(arhdr,0x20,sizeof(*arhdr));
@@ -33,8 +48,7 @@ static void mdso_argen_common_hdr(
arhdr->ar_file_mode[0] = '0';
arhdr->ar_time_date_stamp[0] = '0';
- slen = sprintf(sbuf,"%zu",size);
- memcpy(arhdr->ar_file_size,sbuf,slen);
+ mdso_obj_write_dec(arhdr->ar_file_size,size);
arhdr->ar_end_tag[0] = 0x60;
arhdr->ar_end_tag[1] = 0x0a;
@@ -212,9 +226,7 @@ int mdso_argen_common(
idx += sizeof(uint32_t);
}
- sprintf(
- objname,"s%06zu.o",
- psym - symv);
+ mdso_obj_write_objname(objname,psym - symv);
ret = mdso_objgen_symentry(dctx,*psym,pobj);