Code Room
Vibe codingMediumvc-g347
Subject Ai code reviewLevel Mid–Senior~16 minCommon in Networking & APIs interviewsIndustries Telecom, Software development

Question

An AI wrote this C UDP receive loop for a telemetry collector. Large datagrams come through 'corrupted'. Find the bug, the datagram size that triggers it, and the fix.

c
#define BUF 512void recv_loop(int sock) {    char buf[BUF];    struct sockaddr_in from;    socklen_t fl = sizeof(from);    for (;;) {        ssize_t n = recvfrom(sock, buf, BUF, 0, (struct sockaddr*)&from, &fl);        if (n <= 0) continue;        handle_datagram(buf, n);   // parses buf as a full message    }}
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.