Skip to contentSkip to conversation

pv-grub: correct sizeof usage

PATCH In review Matthew Daley 2 participants 2 messages Mar 29, 2014 – Mar 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pv-grub: correct sizeof usage

We were lucky that sizeof(frame) >= sizeof(*frame) anyway.

---
 stubdom/grub/mini-os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
stubdom/grub/mini-os.c +1 -1
index 64ab962..9d4bcc7 100644
@@ -333,7 +333,7 @@ struct frame {
 static void minios_transmit (struct nic *nic, const char *d, unsigned int t,
                              unsigned int s, const char *p)
 {
-    struct frame *frame = alloca(sizeof(frame) + s);
+    struct frame *frame = alloca(sizeof(*frame) + s);
 
     memcpy(frame->dest, d, ETH_ALEN);
     memcpy(frame->src, nic->node_addr, ETH_ALEN);
Signature · 1 line
1.9.0
#1 lore raw
Quoted 1 line · Matthew Daley, le Sat 29 Mar 2014 18:08:08 +1300, a écrit :

We were lucky that sizeof(frame) >= sizeof(*frame) anyway.

Ouch, indeed!

Quoted 1 line
Quoted 20 lines
---
 stubdom/grub/mini-os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
stubdom/grub/mini-os.c +1 -1
index 64ab962..9d4bcc7 100644
@@ -333,7 +333,7 @@ struct frame {
 static void minios_transmit (struct nic *nic, const char *d, unsigned int t,
                              unsigned int s, const char *p)
 {
-    struct frame *frame = alloca(sizeof(frame) + s);
+    struct frame *frame = alloca(sizeof(*frame) + s);
 
     memcpy(frame->dest, d, ETH_ALEN);
     memcpy(frame->src, nic->node_addr, ETH_ALEN);
Signature · 1 line
1.9.0
Signature · 3 lines
Samuel
<D> N: j'aime bien Cut d'un truc enorme... ca montre de quel cote de l'ecran sont les couilles :)))
 -+- #ens-mim et la peufeupeu -+-