summaryrefslogtreecommitdiffstats
path: root/src/dbi.h
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-10-06 14:19:06 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-10-06 16:04:17 +0200
commitf537dafa775307255019df9a119c8f81a52607ca (patch)
tree3b3863f88e514ddbfc5d25be335cdb478a5a0174 /src/dbi.h
parent27fbc658293db97775385f6cc54a36bf0d6c454d (diff)
#941 Use fixed length strings in og_computer and og_dbi_get_computer_info
This patch is a refactor for og_computer and og_dbi_get_computer_info. It now uses fixed lenght strings to make it more reliable and avoid errors if the DB is not returning a null ended string.
Diffstat (limited to 'src/dbi.h')
-rw-r--r--src/dbi.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/dbi.h b/src/dbi.h
index 84b898c..e92ce43 100644
--- a/src/dbi.h
+++ b/src/dbi.h
@@ -23,10 +23,16 @@ void og_dbi_close(struct og_dbi *db);
#define OG_DB_COMPUTER_NAME_MAXLEN 100
#define OG_DB_CENTER_NAME_MAXLEN 100
#define OG_DB_ROOM_NAME_MAXLEN 100
+#define OG_DB_SERIAL_NUMBER_MAXLEN 25
#define OG_DB_IMAGE_NAME_MAXLEN 50
#define OG_DB_FILESYSTEM_MAXLEN 16
+#define OG_DB_NETDRIVER_MAXLEN 30
+#define OG_DB_NETIFACE_MAXLEN 4
+#define OG_DB_LIVEDIR_MAXLEN 50
#define OG_DB_INT8_MAXLEN 8
+#define OG_DB_BOOT_MAXLEN 30
#define OG_DB_INT_MAXLEN 11
+#define OG_DB_MAC_MAXLEN 15
#define OG_DB_IP_MAXLEN 15
#define OG_DB_SMALLINT_MAXLEN 6
@@ -59,20 +65,19 @@ struct og_computer {
unsigned int id;
bool maintenance;
bool remote;
- char *serial_number;
- char *netdriver;
- char *netiface;
- char *netmask;
- char *livedir;
- char *name;
- char *boot;
- char *mac;
- char *ip;
+ char serial_number[OG_DB_SERIAL_NUMBER_MAXLEN + 1];
+ char netdriver[OG_DB_NETDRIVER_MAXLEN + 1];
+ char name[OG_DB_COMPUTER_NAME_MAXLEN + 1];
+ char netiface[OG_DB_NETIFACE_MAXLEN + 1];
+ char livedir[OG_DB_LIVEDIR_MAXLEN + 1];
+ char netmask[OG_DB_IP_MAXLEN + 1];
+ char boot[OG_DB_BOOT_MAXLEN + 1];
+ char mac[OG_DB_MAC_MAXLEN + 1];
+ char ip[OG_DB_IP_MAXLEN + 1];
};
struct in_addr;
int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer,
struct in_addr addr);
-void og_dbi_free_computer_info(struct og_computer *computer);
#endif